File tree Expand file tree Collapse file tree 1 file changed +16
-20
lines changed Expand file tree Collapse file tree 1 file changed +16
-20
lines changed Original file line number Diff line number Diff line change @@ -951,10 +951,8 @@ impl SymbolTableBuilder {
951
951
let table = self . tables . last_mut ( ) . unwrap ( ) ;
952
952
let location = Default :: default ( ) ;
953
953
954
- // Some checks:
955
- let containing = table. symbols . contains_key ( name) ;
956
- if containing {
957
- let symbol = table. symbols . get ( name) . unwrap ( ) ;
954
+ // Some checks for the symbol that present on this scope level:
955
+ if let Some ( symbol) = table. symbols . get ( name) {
958
956
// Role already set..
959
957
match role {
960
958
SymbolUsage :: Global => {
@@ -1000,23 +998,21 @@ impl SymbolTableBuilder {
1000
998
// Ok?
1001
999
}
1002
1000
}
1003
- }
1004
-
1005
- // Some more checks:
1006
- match role {
1007
- SymbolUsage :: Nonlocal if scope_depth < 2 => {
1008
- return Err ( SymbolTableError {
1009
- error : format ! ( "cannot define nonlocal '{}' at top level." , name) ,
1010
- location,
1011
- } )
1012
- }
1013
- _ => {
1014
- // Ok!
1001
+ } else {
1002
+ // The symbol does not present on this scope level.
1003
+ // Some checks to insert new symbol into symbol table:
1004
+ match role {
1005
+ SymbolUsage :: Nonlocal if scope_depth < 2 => {
1006
+ return Err ( SymbolTableError {
1007
+ error : format ! ( "cannot define nonlocal '{}' at top level." , name) ,
1008
+ location,
1009
+ } )
1010
+ }
1011
+ _ => {
1012
+ // Ok!
1013
+ }
1015
1014
}
1016
- }
1017
-
1018
- // Insert symbol when required:
1019
- if !containing {
1015
+ // Insert symbol when required:
1020
1016
let symbol = Symbol :: new ( name) ;
1021
1017
table. symbols . insert ( name. to_owned ( ) , symbol) ;
1022
1018
}
You can’t perform that action at this time.
0 commit comments