diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index e50b50331c..9643f37655 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -2523,9 +2523,15 @@ proc paramTypesMatchAux(m: var TCandidate, f, a: PType, result = arg elif skipTypes(arg.typ, abstractVar-{tyTypeDesc}).kind == tyTuple or cmpInheritancePenalty(oldInheritancePenalty, m.inheritancePenalty) > 0: result = implicitConv(nkHiddenSubConv, f, arg, m, c) - elif arg.typ.isEmptyContainer: + elif arg.typ.isEmptyContainer or + # XXX `and not m.isNoCall` is a workaround + # passing an int to generic types converts it to the type `int` + # but this isn't done for int literal types, so we preserve the type + # i.e. works: `type Foo[T] = array[T, int]; var x: Foo[3]` (see t12938, t14193) + # doesn't work: `proc foo[T](): array[T, int] = ...; foo[3]()` (see #23204) + (arg.typ.isIntLit and not m.isNoCall): result = arg.copyTree - result.typ = getInstantiatedType(c, arg, m, f) + result.typ = getInstantiatedType(c, arg, m, f).skipTypes({tySink}) else: result = arg of isBothMetaConvertible: diff --git a/tests/generics/t14193.nim b/tests/generics/t14193.nim index 213b1a8e6e..8dab666e42 100644 --- a/tests/generics/t14193.nim +++ b/tests/generics/t14193.nim @@ -1,5 +1,5 @@ type - Task*[N: int] = object + Task*[N: int] = object # XXX this shouldn't work, should be `static int` env*: array[N, byte] var task14193: Task[20] diff --git a/tests/js/tint64litgen.nim b/tests/js/tint64litgen.nim new file mode 100644 index 0000000000..240bbc6a02 --- /dev/null +++ b/tests/js/tint64litgen.nim @@ -0,0 +1,30 @@ +discard """ + matrix: "--jsbigint64:on; --jsbigint64:off" +""" + +block: # issue #24233 + proc foo[T: SomeInteger](a, b: T) = + let x = a div b + + const bar = 123 + + let x: int64 = 456 + foo(x, bar) + +block: # issue #24233, modified + proc f(a, b: int64) = + let x = a div b + + proc foo[T: SomeInteger](a, b: T) = + f(a, b) + + const bar = 123 + + let x: int64 = 456 + foo(x, bar) + +block: + proc foo[I: Ordinal](x: I) = discard + foo(123) + let x = [0, 1, 2] + discard x[0]