Skip to content

Conversation

@rcosta358
Copy link
Collaborator

@rcosta358 rcosta358 commented Nov 22, 2025

This PR fixes the problem mentioned in #126, where we were getting a not found error instead of an argument mismatch error on wrong alias invocations, because we were not validating them beforehand. Also, we were previously relying on the Z3 output to get ghost invocation errors. Instead, we now also validate ghost calls before sending them to the SMT solver. For both ghosts and aliases, in either wrong argument count or types, the ArgumentMismatchError was introduced.

Needs rebase after #126 is merged

@rcosta358 rcosta358 self-assigned this Nov 22, 2025
@rcosta358 rcosta358 added the enhancement New feature or request label Nov 22, 2025
@rcosta358 rcosta358 changed the title Improve Error Handling Fix Alias & Ghost Argument Mismatch Nov 22, 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.

Merge previous PR and rebase pls. These are too many files to review 😅

@rcosta358
Copy link
Collaborator Author

Sure thing! Let me just finish up #126.

- Add ArgumentMismatchError
- Check argument count and types of aliases
- Add not found error for aliases as well
- Add locations to LJErrors after catching them in the places they don't include positions
- Validate ghost invocations instead of relying on Z3 output
- Throw LJErrors in AST expressions
@rcosta358 rcosta358 force-pushed the fix-argument-mismatch branch from bc9c458 to ea9d845 Compare December 4, 2025 11:26
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.

left some comments

}

// no overload matched, use the first candidate to throw the error
GhostFunction g = candidates.get(0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we provide the hints in here instead of creating an error with the first candidate? Like "gh(int) not found. Maybe you meant gh(double), gh(int, double)"
Similar to what you did on the warning for external method not found

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Definitely! I'll do that in another PR with more cases.

*
* @throws LJError
*/
public void validateGhostInvocations(Context ctx, Factory f) throws LJError {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this method is too long. check the suggestions i left, it might improve. If not, we might need to split this into smaller bits

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed.

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.

lgtm

@rcosta358 rcosta358 merged commit 883171c into main Dec 4, 2025
1 check passed
@rcosta358 rcosta358 deleted the fix-argument-mismatch branch December 4, 2025 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants