Skip to content

Commit aa37de2

Browse files
committed
Add Ghost Not Found Test Case
1 parent e105b17 commit aa37de2

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Not Found Error
2+
package testSuite;
3+
4+
import liquidjava.specification.Refinement;
5+
6+
public class ErrorGhostNotFound {
7+
8+
public void test() {
9+
@Refinement("notFound(x)")
10+
int x = 5;
11+
}
12+
}

liquidjava-verifier/src/main/java/liquidjava/rj_language/ast/Expression.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,13 @@ public void validateGhostInvocations(Context ctx, Factory f) throws LJError {
271271
if (this instanceof FunctionInvocation fi) {
272272
// get all ghosts with the matching name
273273
List<GhostFunction> candidates = ctx.getGhosts().stream().filter(g -> g.matches(fi.name)).toList();
274-
if (candidates.isEmpty())
275-
return;
274+
if (candidates.isEmpty())
275+
return; // not found error is thrown elsewhere
276276

277277
// find matching overload
278-
Optional<GhostFunction> match = candidates.stream().filter(g -> argumentsMatch(fi, g, ctx, f)).findFirst();
279-
if (match.isEmpty()) {
280-
// no overload matched, use the first candidate to throw the error
278+
Optional<GhostFunction> found = candidates.stream().filter(g -> argumentsMatch(fi, g, ctx, f)).findFirst();
279+
if (found.isEmpty()) {
280+
// no overload found, use the first candidate to throw the error
281281
throwArgumentMismatchError(fi, candidates.get(0), ctx, f);
282282
}
283283
}

0 commit comments

Comments
 (0)