Skip to content
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

Better control over error locations for strict contracts #2053

Open
jneem opened this issue Sep 26, 2024 · 0 comments
Open

Better control over error locations for strict contracts #2053

jneem opened this issue Sep 26, 2024 · 0 comments

Comments

@jneem
Copy link
Member

jneem commented Sep 26, 2024

When composing lazy contracts, the reported error position is typically the innermost error: { a = "hi" } | { a | String } will blame just the a and not the whole record. This is usually the correct behavior, I think.

When building up an eager contract by recursively calling std.contract.check on other eager contracts, a contract failure will blame the outermost contract. This is inherent to the signature of std.contract.check, as the inner calls to std.contract.check can only return error messages; the location tracking is only performed at the call to %contract/apply%.

Maybe error case std.contract.check could be modified to return { message, notes, location | optional | Dyn } (i.e. with the new location parameter), where location is an opaque value representing the error location. Then the location could be threaded through recursive calls to std.contract.check, allowing the contract author to decide on the best error location. Maybe location should be locations, an array of locations and error message, to reflect that there can be multiple diagnostic locations tagged with different messages.

Related to #1432, in that they could use the same mechanism for tracking locations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant