GH-2669: Give script location for type clash in for-loop construction

This commit is contained in:
Tim Wojtulewicz 2023-01-25 14:38:25 -07:00
parent c414136288
commit 5e68880470
2 changed files with 4 additions and 4 deletions

View file

@ -1249,7 +1249,7 @@ ForStmt::ForStmt(IDPList* arg_loop_vars, ExprPtr loop_expr)
else if ( lvt ) else if ( lvt )
{ {
if ( ! same_type(lvt, ind_type) ) if ( ! same_type(lvt, ind_type) )
lvt->Error("type clash in iteration", ind_type.get()); e->Error("type clash in iteration", lvt.get());
} }
else else
@ -1341,7 +1341,7 @@ ForStmt::ForStmt(IDPList* arg_loop_vars, ExprPtr loop_expr, IDPtr val_var)
else if ( value_var->GetType() ) else if ( value_var->GetType() )
{ {
if ( ! same_type(value_var->GetType(), yield_type) ) if ( ! same_type(value_var->GetType(), yield_type) )
value_var->GetType()->Error("type clash in iteration", yield_type.get()); e->Error("type clash in iteration", value_var->GetType().get());
} }
else else
add_local(value_var, yield_type, INIT_NONE, nullptr, nullptr, VAR_REGULAR); add_local(value_var, yield_type, INIT_NONE, nullptr, nullptr, VAR_REGULAR);

View file

@ -1,5 +1,5 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
error in <...>/for-var-check.zeek, line 4: global variable used in 'for' loop (x) error in <...>/for-var-check.zeek, line 4: global variable used in 'for' loop (x)
error in error and count: type clash in iteration (error and count) error in <...>/for-var-check.zeek, line 10 and error: type clash in iteration (set(1, 2, 3) and error)
error in <...>/for-var-check.zeek, line 8: constant used in 'for' loop (y) error in <...>/for-var-check.zeek, line 8: constant used in 'for' loop (y)
error in error and count: type clash in iteration (error and count) error in <...>/for-var-check.zeek, line 11 and error: type clash in iteration (set(1, 2, 3) and error)