Skip to content

Commit 3cdb20b

Browse files
author
RajShivu
committed
Fix refinement variable mapping: '_' and 'return' →
1 parent 1b290cb commit 3cdb20b

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

liquidjava-verifier/src/main/java/liquidjava/rj_language/visitors/CreateASTVisitor.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,25 @@ private Expression literalExpressionCreate(ParseTree rc) throws LJError {
154154
return new GroupExpression(create(((LitGroupContext) rc).literalExpression()));
155155
else if (rc instanceof LitContext)
156156
return create(((LitContext) rc).literal());
157+
158+
// else if (rc instanceof VarContext) {
159+
// return new Var(((VarContext) rc).ID().getText());
160+
// }
157161
else if (rc instanceof VarContext) {
158-
return new Var(((VarContext) rc).ID().getText());
159-
} else if (rc instanceof TargetInvocationContext) {
162+
// Normalize return-value identifiers:
163+
// - "return" (legacy syntax)
164+
// - "_" (current shorthand)
165+
// Both are mapped to "$result", the canonical return value identifier.
166+
String name = ((VarContext) rc).ID().getText();
167+
168+
if (name.equals("return") || name.equals("_")) {
169+
name = "$result";
170+
}
171+
172+
return new Var(name);
173+
}
174+
175+
else if (rc instanceof TargetInvocationContext) {
160176
// TODO Finish Invocation with Target (a.len())
161177
return null;
162178
} else {

0 commit comments

Comments
 (0)