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

Generate warnings + multiple errors from within the typechecker #1483

Open
kostmo opened this issue Aug 31, 2023 · 0 comments
Open

Generate warnings + multiple errors from within the typechecker #1483

kostmo opened this issue Aug 31, 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-Developer Experience This issue seeks to make life easier for developers writing Scenarios or other Swarm code. Z-Feature A new feature to be added to the game.

Comments

@kostmo
Copy link
Member

kostmo commented Aug 31, 2023

This is a pre-requisite for LSP support to warn on name shadowing. See #1338 (comment). The idea is that rather than stopping as soon as we encounter an error during typechecking, we simply log the error, make up a new unification variable to represent the type of the problematic subterm (so it won't prevent other things from typechecking), and continue. This way we can generate multiple type errors at once, just like other real-world languages with static typechecking. If we want to be fancy we could even do something like GHC's -fdefer-type-errors where we replace terms that don't type check with calls to error, but allow everything else to load.

Once we are logging errors in some kind of writer monad we can just as easily log warnings as well as errors.

See also:

@kostmo kostmo added Z-Feature A new feature to be added to the game. Z-Developer Experience This issue seeks to make life easier for developers writing Scenarios or other Swarm code. labels Aug 31, 2023
@byorgey byorgey added 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. labels Aug 31, 2023
@byorgey byorgey changed the title generate warnings from within the typechecker Generate warnings + multiple errors from within the typechecker Aug 31, 2023
@byorgey byorgey self-assigned this Aug 31, 2023
mergify bot pushed a commit that referenced this issue Sep 15, 2023
In preparation for #1483.   `LogEntry` started life as something specific to robot logs.  It then evolved to be used in the system log as well (see #1039 and #652), but in a sort of hacky way.  This PR refactors `LogEntry` to be more generic.

- Move `Swarm.Game.Log` -> `Swarm.Log` since it's not specific to gameplay.
- Rename `ErrorLevel` to `Severity`, add a new `Info` level, and add a top-level `leSeverity` field
- Rename `leRobotName` to just `leName`, since it was already being used to name both robots and system components anyway
- Move robot-specific fields (*e.g.* robot ID) into the new `RobotLogSource` type, and add `LogSource` to differentiate between robot and system logs
- Various other minor improvements and tweaks
@byorgey byorgey added the L-Error reporting Reporting language or runtime errors to the player. label Aug 17, 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-Developer Experience This issue seeks to make life easier for developers writing Scenarios or other Swarm code. Z-Feature A new feature to be added to the game.
Projects
None yet
Development

No branches or pull requests

2 participants