File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -132,10 +132,12 @@ fn (mut p Parser) check_undefined_variables(names []string, val ast.Expr) ! {
132132}
133133
134134fn (mut p Parser) check_cross_variables (exprs []ast.Expr, val ast.Expr) bool {
135- // NOTE: val_str must be computed before the match, because inside match arms
136- // `val` gets smartcast to the variant type, and calling .str() on e.g.
137- // IndexExpr would call the auto-generated struct str() instead of Expr.str().
138- val_str := val.str ()
135+ // NOTE: For IndexExpr and SelectorExpr, we need to compare string representations.
136+ // val_str must be computed before the match, because inside match arms `val` gets
137+ // smartcast to the variant type, and calling .str() on e.g. IndexExpr would call
138+ // the auto-generated struct str() instead of Expr.str().
139+ // Only compute it for the types that actually need it.
140+ val_str := if val is ast.IndexExpr || val is ast.SelectorExpr { val.str () } else { '' }
139141 match val {
140142 ast.Ident {
141143 for expr in exprs {
You can’t perform that action at this time.
0 commit comments