compiler: add is_global() check at top of errors
add `!symbol.is_global()` condition check before entrying global symbol
errors
This change will decrease hot path cost.
@@ -1120,6 +1120,7 @@ impl SymbolTableBuilder {
// Role already set..
match role {
SymbolUsage::Global => {
+ if !symbol.is_global() {
if symbol.is_parameter {
return Err(SymbolTableError {
error: format!("name '{}' is parameter and global", name),
@@ -1128,7 +1129,10 @@ impl SymbolTableBuilder {
}
if symbol.is_referenced {
return Err(SymbolTableError {
- error: format!("name '{}' is used prior to global declaration", name),
+ error: format!(
+ "name '{}' is used prior to global declaration",
+ name
+ ),
location,
});
}
@@ -1148,6 +1152,7 @@ impl SymbolTableBuilder {
});
}
}
+ }
SymbolUsage::Nonlocal => {
if symbol.is_parameter {
return Err(SymbolTableError {
