[Nice-commit] Nice/src/bossa/syntax analyse.nice,1.72,1.73
Brought to you by:
bonniot
From: <ar...@us...> - 2003-06-14 12:05:11
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv23450/F:/nice/src/bossa/syntax Modified Files: analyse.nice Log Message: Implemented check for redefining local variable, it's not allowed. Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** analyse.nice 11 Jun 2003 22:24:07 -0000 1.72 --- analyse.nice 14 Jun 2003 12:05:04 -0000 1.73 *************** *** 170,173 **** --- 170,174 ---- symbol.syntacticType = null; } + this.checkNotDefined(symbol); this.vars[symbol.name.toString()] = symbol; } *************** *** 182,186 **** throw error(symbol, "A variable cannot have a void type"); } ! this.vars[symbol.name.toString()] = symbol; } --- 183,187 ---- throw error(symbol, "A variable cannot have a void type"); } ! this.checkNotDefined(symbol); this.vars[symbol.name.toString()] = symbol; } *************** *** 191,194 **** --- 192,204 ---- void addTypeVars(Array<TypeSymbol> symbols) = symbols.foreach(TypeSymbol s => this.typeVars[s.toString()] = s); + + void checkNotDefined(VarSymbol symbol) + { + ?VarSymbol old = this.vars[symbol.name.toString()]; + if (old != null) + throw error(symbol, "Symbol " + symbol.name + " is already defined at " + + "line " + old.location().getLine() + + ", column " + old.location().getColumn()); + } } |