Skip to content

Conversation

@rcosta358
Copy link
Collaborator

@rcosta358 rcosta358 commented Nov 13, 2025

This PR is related to #86. Instead of adding this as default argument when none are provided, we throw a ParsingException with the appropriate message instead of failing with index out-of-bounds later on.

Before:

Index 0 out of bounds for length 0

After:

Syntax error with message
Function call cannot have empty arguments
Found in refinement:
size() > 0
In:
@liquidjava.specification.StateRefinement(from = "size() > 0")
void testMethod() {
}

@rcosta358 rcosta358 changed the title Prevent Index-Out-Of-Bounds in Function Call With Empty ARgs Prevent Index-Out-Of-Bounds in Function Call With Empty Args Nov 13, 2025
@rcosta358 rcosta358 changed the title Prevent Index-Out-Of-Bounds in Function Call With Empty Args Prevent Index Out-Of-Bounds in Function Call With Empty Args Nov 13, 2025
@rcosta358 rcosta358 self-assigned this Nov 13, 2025
Copy link
Collaborator

@CatarinaGamboa CatarinaGamboa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small change

return new FunctionInvocation(name, le);
List<Expression> args = getArgs(gc.args());
if (args.isEmpty())
throw new ParsingException("Function call cannot have empty arguments");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can change to "Invocation" or "Alias or State" instead of "Function call" since that is an internal name we use and the user should receive a message with something from their context

@rcosta358 rcosta358 merged commit 87a2153 into main Nov 13, 2025
1 check passed
@rcosta358 rcosta358 deleted the fix-fun-call-index-out-of-bounds branch November 15, 2025 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants