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

Add more context to type errors #1297

Closed
3 tasks done
byorgey opened this issue Jun 1, 2023 · 0 comments
Closed
3 tasks done

Add more context to type errors #1297

byorgey opened this issue Jun 1, 2023 · 0 comments
Assignees
Labels
C-Moderate Effort Should take a moderate amount of time to address. L-Error reporting Reporting language or runtime errors to the player. L-Type inference The process of inferring the type of a Swarm expression. S-Moderate The fix or feature would substantially improve user experience. Z-Feature A new feature to be added to the game. Z-User Experience This issue seeks to make the game more enjoyable to play.

Comments

@byorgey
Copy link
Member

byorgey commented Jun 1, 2023

Type errors now give a precise source location, but it would be nice to add extra information about the context at the time the type error occurred, for example

  • The expression we were checking
  • Why we were expecting the type that we did
  • Relevant things that are in scope

See:

@byorgey byorgey added Z-User Experience This issue seeks to make the game more enjoyable to play. Z-Feature A new feature to be added to the game. C-Moderate Effort Should take a moderate amount of time to address. S-Moderate The fix or feature would substantially improve user experience. L-Type inference The process of inferring the type of a Swarm expression. L-Error reporting Reporting language or runtime errors to the player. labels Jun 1, 2023
@byorgey byorgey self-assigned this Jun 1, 2023
mergify bot pushed a commit that referenced this issue Jun 10, 2023
Towards #1297 .  In this PR:

- Moves some functions out of `Pipeline` and into more appropriate modules
- Adds a new type `Join` to represent two types or other things, one "expected" and one "actual", at the point where they join + we check whether they are equal; a bunch of refactoring to use this new type.  This way we don't have to remember which argument is which when calling a function that takes one "expected" thing and one "actual" thing.
- Refactors all the `decomposeXXX` functions to take a `Syntax` node to use in error messages, and to take a `Sourced UType` (*i.e.* a `UType` along with whether it is "expected" or "actual") instead of just a `UType` so we can generate accurate error messages
- Introduce a basic typechecking stack that keeps track of "what we are currently in the middle of checking", so that when we encounter an error we can say things like "while checking the definition of `foo`".  Currently this is just a basic proof of concept.
- A few other miscellaneous error message improvements.
@byorgey byorgey closed this as completed Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Moderate Effort Should take a moderate amount of time to address. L-Error reporting Reporting language or runtime errors to the player. L-Type inference The process of inferring the type of a Swarm expression. S-Moderate The fix or feature would substantially improve user experience. Z-Feature A new feature to be added to the game. Z-User Experience This issue seeks to make the game more enjoyable to play.
Projects
None yet
Development

No branches or pull requests

1 participant