Skip to content

Commit

Permalink
fixes #22971; inferGenericTypes does not work with method call synt…
Browse files Browse the repository at this point in the history
…ax (#22972)

fixes #22971
  • Loading branch information
Pylgos authored Nov 22, 2023
1 parent 8c56e80 commit eba87c7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags; expectedType: PType
result.transitionSonsKind(nkCall)
result.flags.incl nfExplicitCall
for i in 1..<n.len: result.add n[i]
return semExpr(c, result, flags)
return semExpr(c, result, flags, expectedType)
else:
n[0] = n0
else:
Expand Down Expand Up @@ -3124,7 +3124,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}, expectedType: PType
result = semFieldAccess(c, n, flags)
if result.kind == nkDotCall:
result.transitionSonsKind(nkCall)
result = semExpr(c, result, flags)
result = semExpr(c, result, flags, expectedType)
of nkBind:
message(c.config, n.info, warnDeprecated, "bind is deprecated")
result = semExpr(c, n[0], flags, expectedType)
Expand Down
24 changes: 23 additions & 1 deletion tests/generics/treturn_inference.nim
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,26 @@ block:

let res = doStuff()
doAssert res.kind == Error
doAssert res.errVal == "Error"
doAssert res.errVal == "Error"

# ufcs
block:
proc getValue[T](_: string): T =
doAssert T is int
44

proc `'test`[T](_: string): T =
55

let a: int = getValue("")
let b: int = "".getValue()
let c: int = "".getValue
let d: int = getValue ""
let e: int = getValue""
let f: int = 12345'test
doAssert a == 44
doAssert b == 44
doAssert c == 44
doAssert d == 44
doAssert e == 44
doAssert f == 55

0 comments on commit eba87c7

Please sign in to comment.