diff --git a/compiler/hlo.nim b/compiler/hlo.nim index de0fa6216f..9491eef832 100644 --- a/compiler/hlo.nim +++ b/compiler/hlo.nim @@ -84,7 +84,7 @@ proc hlo(c: PContext, n: PNode): PNode = if isEmptyType(n.typ) and isEmptyType(result.typ): discard else: - result = fitNode(c, n.typ, result) + result = fitNode(c, n.typ, result, n.info) # optimization has been applied so check again: result = commonOptimizations(c.module, result) result = hlo(c, result) diff --git a/compiler/parser.nim b/compiler/parser.nim index 902bf0fcb1..272c1b15fc 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -514,12 +514,12 @@ proc parsePar(p: var TParser): PNode = var a = simpleExpr(p) if p.tok.tokType == tkEquals: # special case: allow assignments + let asgn = newNodeP(nkAsgn, p) getTok(p) optInd(p, result) let b = parseExpr(p) - let asgn = newNodeI(nkAsgn, a.info, 2) - asgn.sons[0] = a - asgn.sons[1] = b + asgn.add a + asgn.add b result.add(asgn) if p.tok.tokType == tkSemiColon: semiStmtList(p, result) @@ -1184,10 +1184,10 @@ proc parseExprStmt(p: var TParser): PNode = #| ))? var a = simpleExpr(p) if p.tok.tokType == tkEquals: + result = newNodeP(nkAsgn, p) getTok(p) optInd(p, result) var b = parseExpr(p) - result = newNodeI(nkAsgn, a.info) addSon(result, a) addSon(result, b) else: diff --git a/compiler/sem.nim b/compiler/sem.nim index 682e9d0ca7..8da5d47079 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -32,7 +32,7 @@ proc semExprNoType(c: PContext, n: PNode): PNode proc semExprNoDeref(c: PContext, n: PNode, flags: TExprFlags = {}): PNode proc semProcBody(c: PContext, n: PNode): PNode -proc fitNode(c: PContext, formal: PType, arg: PNode): PNode +proc fitNode(c: PContext, formal: PType, arg: PNode; info: TLineInfo): PNode proc changeType(n: PNode, newType: PType, check: bool) proc semLambda(c: PContext, n: PNode, flags: TExprFlags): PNode @@ -69,7 +69,7 @@ template semIdeForTemplateOrGeneric(c: PContext; n: PNode; # echo "passing to safeSemExpr: ", renderTree(n) discard safeSemExpr(c, n) -proc fitNode(c: PContext, formal: PType, arg: PNode): PNode = +proc fitNode(c: PContext, formal: PType, arg: PNode; info: TLineInfo): PNode = if arg.typ.isNil: localError(arg.info, errExprXHasNoType, renderTree(arg, {renderNoComments})) @@ -79,7 +79,7 @@ proc fitNode(c: PContext, formal: PType, arg: PNode): PNode = else: result = indexTypesMatch(c, formal, arg.typ, arg) if result == nil: - typeMismatch(arg, formal, arg.typ) + typeMismatch(info, formal, arg.typ) # error correction: result = copyTree(arg) result.typ = formal @@ -367,7 +367,7 @@ proc semAfterMacroCall(c: PContext, n: PNode, s: PSym, #result = symNodeFromType(c, typ, n.info) else: result = semExpr(c, result, flags) - result = fitNode(c, s.typ.sons[0], result) + result = fitNode(c, s.typ.sons[0], result, result.info) #GlobalError(s.info, errInvalidParamKindX, typeToString(s.typ.sons[0])) dec(evalTemplateCounter) discard c.friendModules.pop() @@ -390,12 +390,12 @@ proc semMacroExpr(c: PContext, n, nOrig: PNode, sym: PSym, popInfoContext() proc forceBool(c: PContext, n: PNode): PNode = - result = fitNode(c, getSysType(tyBool), n) + result = fitNode(c, getSysType(tyBool), n, n.info) if result == nil: result = n proc semConstBoolExpr(c: PContext, n: PNode): PNode = let nn = semExprWithType(c, n) - result = fitNode(c, getSysType(tyBool), nn) + result = fitNode(c, getSysType(tyBool), nn, nn.info) if result == nil: localError(n.info, errConstExprExpected) return nn diff --git a/compiler/semcall.nim b/compiler/semcall.nim index fe73d60e6a..98667b0857 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -327,7 +327,7 @@ proc inferWithMetatype(c: PContext, formal: PType, result.typ = generateTypeInstance(c, m.bindings, arg.info, formal.skipTypes({tyCompositeTypeClass})) else: - typeMismatch(arg, formal, arg.typ) + typeMismatch(arg.info, formal, arg.typ) # error correction: result = copyTree(arg) result.typ = formal diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 6db7724f98..ba60442d6f 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -194,13 +194,13 @@ proc semConv(c: PContext, n: PNode): PNode = of convOK: # handle SomeProcType(SomeGenericProc) if op.kind == nkSym and op.sym.isGenericRoutine: - result.sons[1] = fitNode(c, result.typ, result.sons[1]) + result.sons[1] = fitNode(c, result.typ, result.sons[1], result.info) elif op.kind == nkPar and targetType.kind == tyTuple: - op = fitNode(c, targetType, op) + op = fitNode(c, targetType, op, result.info) of convNotNeedeed: message(n.info, hintConvFromXtoItselfNotNeeded, result.typ.typeToString) of convNotLegal: - result = fitNode(c, result.typ, result.sons[1]) + result = fitNode(c, result.typ, result.sons[1], result.info) if result == nil: localError(n.info, errGenerated, msgKindToString(errIllegalConvFromXtoY)% [op.typ.typeToString, result.typ.typeToString]) @@ -445,7 +445,7 @@ proc semArrayConstr(c: PContext, n: PNode, flags: TExprFlags): PNode = x = n.sons[i] if x.kind == nkExprColonExpr and sonsLen(x) == 2: var idx = semConstExpr(c, x.sons[0]) - idx = fitNode(c, indexType, idx) + idx = fitNode(c, indexType, idx, x.info) if lastIndex+1 != getOrdValue(idx): localError(x.info, errInvalidOrderInArrayConstructor) x = x.sons[1] @@ -458,7 +458,7 @@ proc semArrayConstr(c: PContext, n: PNode, flags: TExprFlags): PNode = inc(lastIndex) addSonSkipIntLit(result.typ, typ) for i in 0 ..