Skip to content

Commit

Permalink
try fix weave, t14509, adapt #23438 for union, tmacrogenerics
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Aug 16, 2024
1 parent c767e45 commit cb7ed67
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion compiler/semcall.nim
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ proc semOverloadedCall(c: PContext, n, nOrig: PNode,
candidates)
result = semResolvedCall(c, r, n, flags, expectedType)
else:
if efDetermineType in flags and c.inGenericContext > 0 and c.matchedConcept == nil:
if c.inGenericContext > 0 and c.matchedConcept == nil:
result = semGenericStmt(c, n)
result.typ = makeTypeFromExpr(c, result.copyTree)
elif efExplain notin flags:
Expand Down
2 changes: 1 addition & 1 deletion compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ proc semOverloadedCallAnalyseEffects(c: PContext, n: PNode, nOrig: PNode,

if result != nil:
if result[0].kind != nkSym:
if not (efDetermineType in flags and c.inGenericContext > 0):
if not (c.inGenericContext > 0): # see generic context check in semOverloadedCall
internalError(c.config, "semOverloadedCallAnalyseEffects")
return
let callee = result[0].sym
Expand Down
2 changes: 2 additions & 0 deletions compiler/semtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,8 @@ proc semTypeExpr(c: PContext, n: PNode; prev: PType): PType =
# unnecessary new type creation
let alias = maybeAliasType(c, result, prev)
if alias != nil: result = alias
elif n.typ.kind == tyFromExpr and c.inGenericContext > 0:
result = n.typ
else:
localError(c.config, n.info, "expected type, but got: " & n.renderTree)
result = errorType(c)
Expand Down
3 changes: 2 additions & 1 deletion compiler/sigmatch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,8 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
# when `f` is an unresolved typedesc, `a` could be any
# type, so we should not perform this check earlier
if c.c.inGenericContext > 0 and
a.skipTypes({tyTypeDesc}).kind == tyGenericParam:
a.skipTypes({tyTypeDesc}).kind == tyGenericParam and
not (c.calleeSym != nil and c.calleeSym.kind in {skMacro, skTemplate}):
# generic type bodies can sometimes compile call expressions
# prevent unresolved generic parameters from being passed to procs as
# typedesc parameters
Expand Down

0 comments on commit cb7ed67

Please sign in to comment.