GeezerVison is showing github.com — Add `#result` for Return Refinements by rajshivu · Pull Request #145 · liquid-java/liquidjava
Add #result for Return Refinements
#145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9d7e2dc
feat: implement support and restore test infrastructure
Feb 10, 2026
e111574
TestMultiple: restored original
Feb 10, 2026
ab4d600
Assert: checked assert validation tests
Feb 11, 2026
58a5475
Fix refinement handling in rj grammar
Feb 11, 2026
a3bee27
Support as a restricted refinement variable
Feb 13, 2026
515ddf5
Remove commented-out code from CreateASTVisitor
Feb 13, 2026
b38a5fc
Merge branch 'main' into feature-result-refinement
rajshivu Feb 15, 2026
a0edc1f
Remove obsolete code and cleanup comments
rajshivu Feb 15, 2026
4969ce5
resolved the conflict in CreateASTVisitor
rajshivu Feb 15, 2026
98d9760
Update: to #result
rajshivu Feb 15, 2026
File filter
Filter by extension
.g4
(1)
.java
(4)
All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,16 @@
package testSuite;
import liquidjava.specification.Refinement;
public class CorrectResult {
@Refinement("#result > 10")
public int getLargeNumber() {
return 15;
}
@Refinement("#result == (a + b)")
public int sum(int a, int b) {
return a + b;
}
}
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,10 @@
// Not Found Error
package testSuite;
import liquidjava.specification.Refinement;
public class ErrorResultVariable {
public void test() {
@Refinement("#result > 0")
int x = 10;
}
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -36,6 +36,7 @@ operand:
literalExpression:
'(' literalExpression ')' #litGroup
| literal #lit
| RESULT #result
| ID #var
| functionCall #invocation
;
Expand Down
Expand Up
@@ -95,7 +96,8 @@ ARITHOP : '+'|'*'|'/'|'%';//|'-';
BOOL : 'true' | 'false';
ID_UPPER: ([A-Z][a-zA-Z0-9]*);
OBJECT_TYPE:
(([a-zA-Z][a-zA-Z0-9]+) ('.' [a-zA-Z][a-zA-Z0-9]*)+);
(([a-zA-Z][a-zA-Z0-9]+) ('.' [a-zA-Z][a-zA-Z0-9]*)+);
RESULT : '#result';
ID : '#'*[a-zA-Z_][a-zA-Z0-9_#]*;
STRING : '"'(~["])*'"';
INT : (([0-9]+) | ([0-9]+('_'[0-9]+)*));
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -162,6 +162,7 @@ private Predicate handleFunctionRefinements(RefinedFunction f, CtElement method,
Optional<Predicate> oret = rtc.getRefinementFromAnnotation(method);
Predicate ret = oret.orElse(new Predicate());
ret = ret.substituteVariable("return", Keys.WILDCARD);
ret = ret.substituteVariable("#result", Keys.WILDCARD);
f.setRefReturn(ret);
rtc.getMessageFromAnnotation(method).ifPresent(f::setMessage);
return Predicate.createConjunction(joint, ret);
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -51,6 +51,7 @@
import rj.grammar.RJParser.PredLogicContext;
import rj.grammar.RJParser.PredNegateContext;
import rj.grammar.RJParser.ProgContext;
import rj.grammar.RJParser.ResultContext;
import rj.grammar.RJParser.StartContext;
import rj.grammar.RJParser.StartPredContext;
import rj.grammar.RJParser.VarContext;
Expand Down
Expand Up
@@ -158,10 +159,14 @@ else if (rc instanceof LitContext)
return create(((LitContext) rc).literal());
else if (rc instanceof VarContext) {
return new Var(((VarContext) rc).ID().getText());
} else {
} else if (rc instanceof ResultContext) {
return new Var("#result");
} else if (rc instanceof InvocationContext) {
return create(((InvocationContext) rc).functionCall());
} else {
throw new IllegalStateException("Unknown literalExpression: " + rc.getClass());
}
}
private Expression functionCallCreate(FunctionCallContext rc) throws LJError {
Expand Down
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.