diff --git a/compiler/semcall.nim b/compiler/semcall.nim index a136cf4fe9d4..3981d256fd71 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -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: diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 0147245af4c6..b5ae05e245e6 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -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 diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index d344f990fce9..eff2cbeb843e 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -1684,6 +1684,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) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 744e0ff8bca0..9b830ac08adb 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -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