Skip to content

Commit

Permalink
fix tests, don't call fitNode for default param if expr type generic
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Aug 27, 2024
1 parent 3f06f36 commit 122ab25
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion compiler/semtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode,
# if def.typ != nil and def.typ.kind != tyNone:
# example code that triggers it:
# proc sort[T](cmp: proc(a, b: T): int = cmp)
if not containsGenericType(typ):
if not containsGenericType(typ) and not containsGenericType(def.typ):
# check type compatibility between def.typ and typ:
def = fitNode(c, typ, def, def.info)
elif typ.kind == tyStatic:
Expand Down
6 changes: 3 additions & 3 deletions tests/generics/tstatic_constrained.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ but expected: <T: float or string, Y>
tstatic_constrained.nim(44, 22) Error: cannot instantiate MyOtherType [type declared in tstatic_constrained.nim(30, 5)]
got: <typedesc[int], int literal(10)>
but expected: <T: float or string, Y>
tstatic_constrained.nim(44, 31) Error: object constructor needs an object type [proxy]
tstatic_constrained.nim(44, 31) Error: object constructor needs an object type [error]
tstatic_constrained.nim(44, 31) Error: expression '' has no type (or is ambiguous)
tstatic_constrained.nim(45, 22) Error: cannot instantiate MyOtherType [type declared in tstatic_constrained.nim(30, 5)]
got: <typedesc[byte], uint8>
but expected: <T: float or string, Y>
tstatic_constrained.nim(45, 22) Error: cannot instantiate MyOtherType [type declared in tstatic_constrained.nim(30, 5)]
got: <typedesc[byte], uint8>
but expected: <T: float or string, Y>
tstatic_constrained.nim(45, 34) Error: object constructor needs an object type [proxy]
tstatic_constrained.nim(45, 34) Error: object constructor needs an object type [error]
tstatic_constrained.nim(45, 34) Error: expression '' has no type (or is ambiguous)
tstatic_constrained.nim(77, 14) Error: cannot instantiate MyType [type declared in tstatic_constrained.nim(71, 5)]
got: <typedesc[float], float64>
Expand Down Expand Up @@ -76,4 +76,4 @@ block:
b: MyType[string, "hello"]
c: MyType[float, 10d]
d: MyOtherType[MyOtherConstraint[float],MyOtherConstraint[float]()]
e: MyOtherType[MyOtherConstraint[int], MyOtherConstraint[int]()]
e: MyOtherType[MyOtherConstraint[int], MyOtherConstraint[int]()]
4 changes: 2 additions & 2 deletions tests/types/tinheritgenericparameter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ discard """
nimout:'''
tinheritgenericparameter.nim(36, 15) Error: Cannot inherit from: 'MyObject'
tinheritgenericparameter.nim(36, 15) Error: Cannot inherit from: 'MyObject'
tinheritgenericparameter.nim(36, 23) Error: object constructor needs an object type [proxy]
tinheritgenericparameter.nim(36, 23) Error: object constructor needs an object type [error]
tinheritgenericparameter.nim(36, 23) Error: expression '' has no type (or is ambiguous)
tinheritgenericparameter.nim(37, 15) Error: Cannot inherit from: 'int'
tinheritgenericparameter.nim(37, 15) Error: Cannot inherit from: 'int'
tinheritgenericparameter.nim(37, 23) Error: object constructor needs an object type [proxy]
tinheritgenericparameter.nim(37, 23) Error: object constructor needs an object type [error]
tinheritgenericparameter.nim(37, 23) Error: expression '' has no type (or is ambiguous)
'''
"""
Expand Down

0 comments on commit 122ab25

Please sign in to comment.