diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/semdata.nim | 1 | ||||
-rw-r--r-- | compiler/sempass2.nim | 4 | ||||
-rw-r--r-- | compiler/semtypes.nim | 7 | ||||
-rw-r--r-- | compiler/sigmatch.nim | 2 |
4 files changed, 9 insertions, 5 deletions
diff --git a/compiler/semdata.nim b/compiler/semdata.nim index 157761591..27d441000 100644 --- a/compiler/semdata.nim +++ b/compiler/semdata.nim @@ -221,6 +221,7 @@ proc makeTypeSymNode*(c: PContext, typ: PType, info: TLineInfo): PNode = proc makeTypeFromExpr*(c: PContext, n: PNode): PType = result = newTypeS(tyFromExpr, c) + assert n != nil result.n = n proc newTypeWithSons*(c: PContext, kind: TTypeKind, diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index 5434f4f8e..b36103d9e 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -683,12 +683,14 @@ proc track(tracked: PEffects, n: PNode) = for child in n: let last = lastSon(child) if child.kind == nkIdentDefs and last.kind != nkEmpty: - # prevent the all too common 'var x = int' bug: XXX track(tracked, last) for i in 0 .. child.len-3: initVar(tracked, child.sons[i], volatileCheck=false) addAsgnFact(tracked.guards, child.sons[i], last) notNilCheck(tracked, last, child.sons[i].typ) + #if last.kind != nkEmpty: + # prevent the all too common 'var x = int' bug: XXX + # since 'var (a, b): T = ()' is not even allowed, there is always type # inference for (a, b) and thus no nil checking is necessary. of nkCaseStmt: trackCase(tracked, n) diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index d052700b2..048154f12 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -781,9 +781,10 @@ proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode, result.rawAddSon(paramType) for i in 0 .. paramType.sonsLen - 2: - let dummyType = if paramType.sons[i].kind == tyStatic: tyUnknown - else: tyAnything - result.rawAddSon newTypeS(dummyType, c) + if paramType.sons[i].kind == tyStatic: + result.rawAddSon makeTypeFromExpr(c, ast.emptyNode) # aka 'tyUnkown' + else: + result.rawAddSon newTypeS(tyAnything, c) if paramType.lastSon.kind == tyUserTypeClass: result.kind = tyUserTypeClassInst diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 2e37f3bf1..9a99d5200 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1056,7 +1056,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation = of tyFromExpr: # fix the expression, so it contains the already instantiated types - if f.n == nil: return isGeneric + if f.n == nil or f.n.kind == nkEmpty: return isGeneric let reevaluated = tryResolvingStaticExpr(c, f.n) case reevaluated.typ.kind of tyTypeDesc: |