From feb0481ba39c4230ba4459be6ac4b2d9f4b02a3b Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 6 Dec 2022 12:50:16 +0800 Subject: [PATCH] Revert "fixes #20883; Unspecified generic on default value segfaults the compiler" (#21028) Revert "fixes #20883; Unspecified generic on default value segfaults the compiler (#20917)" This reverts commit 10b6e4f5b4a119a8fa42f82a24ae7e4b08b2c103. --- compiler/semtypinst.nim | 6 +----- compiler/sigmatch.nim | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim index 7c8ee0789..945667a81 100644 --- a/compiler/semtypinst.nim +++ b/compiler/semtypinst.nim @@ -81,7 +81,6 @@ type info*: TLineInfo allowMetaTypes*: bool # allow types such as seq[Number] # i.e. the result contains unresolved generics - fromStaticExpr*: bool skipTypedesc*: bool # whether we should skip typeDescs isReturnType*: bool owner*: PSym # where this instantiation comes from @@ -239,8 +238,6 @@ proc replaceTypeVarsN(cl: var TReplTypeVars, n: PNode; start=0): PNode = assert result.kind notin nkCallKinds else: if n.len > 0: - if n.kind in nkCallKinds and n[0].kind == nkIdent and cl.fromStaticExpr: - localError(cl.c.config, n.info, "An unresolved call in staticExpr: '" & renderTree(n) & "'") newSons(result, n.len) if start > 0: result[0] = n[0] @@ -663,11 +660,10 @@ proc initTypeVars*(p: PContext, typeMap: LayeredIdTable, info: TLineInfo; result.owner = owner proc replaceTypesInBody*(p: PContext, pt: TIdTable, n: PNode; - owner: PSym, allowMetaTypes = false, fromStaticExpr = false): PNode = + owner: PSym, allowMetaTypes = false): PNode = var typeMap = initLayeredTypeMap(pt) var cl = initTypeVars(p, typeMap, n.info, owner) cl.allowMetaTypes = allowMetaTypes - cl.fromStaticExpr = fromStaticExpr pushInfoContext(p.config, n.info) result = replaceTypeVarsN(cl, n) popInfoContext(p.config) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 61ccaaf90..591a7c2a2 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -807,8 +807,7 @@ proc tryResolvingStaticExpr(c: var TCandidate, n: PNode, # N is bound to a concrete value during the matching of the first param. # This proc is used to evaluate such static expressions. let instantiated = replaceTypesInBody(c.c, c.bindings, n, nil, - allowMetaTypes = allowUnresolved, - fromStaticExpr = true) + allowMetaTypes = allowUnresolved) result = c.c.semExpr(c.c, instantiated) proc inferStaticParam*(c: var TCandidate, lhs: PNode, rhs: BiggestInt): bool =