File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
types/src/main/java/com/compilerprogramming/ezlang/types Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 11package com .compilerprogramming .ezlang .types ;
22
3+ import com .compilerprogramming .ezlang .exceptions .CompilerException ;
4+
35import java .util .ArrayList ;
46import java .util .LinkedHashMap ;
57import java .util .List ;
@@ -27,7 +29,7 @@ public Scope(Scope parent) {
2729 }
2830
2931 public Symbol lookup (String name ) {
30- Symbol symbol = bindings . get (name );
32+ Symbol symbol = localLookup (name );
3133 if (symbol == null && parent != null )
3234 symbol = parent .lookup (name );
3335 return symbol ;
@@ -38,6 +40,8 @@ public Symbol localLookup(String name) {
3840 }
3941
4042 public Symbol install (String name , Symbol symbol ) {
43+ if (localLookup (name ) != null )
44+ throw new CompilerException ("Symbol " + name + " already defined in scope" );
4145 bindings .put (name , symbol );
4246 return symbol ;
4347 }
You can’t perform that action at this time.
0 commit comments