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

Improve error messages involving skolem variables #2102

Open
byorgey opened this issue Aug 9, 2024 · 0 comments
Open

Improve error messages involving skolem variables #2102

byorgey opened this issue Aug 9, 2024 · 0 comments
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-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. Z-User Experience This issue seeks to make the game more enjoyable to play.

Comments

@byorgey
Copy link
Member

byorgey commented Aug 9, 2024

There are two kinds of error messages we could get involving skolem variables.

  • We can simply get a type mismatch when we try to unify a skolem variable with something else. However, the current error is confusing since it references a made-up variable. For example:

    > def f : a -> a = \x. 3 end
    1:22: Type mismatch:
      From context, expected `3` to have type `s1`,
      but it actually has type `Int`
    
      - While checking the definition of f
    

    It would be better if the error said something about polymorphism and mentioned the type variable a. This might require keeping track of a mapping between generated skolem variables and type variables in the polymorphic type.

  • When a skolem variable escapes, the error message is even worse since the error explicitly mentions the word "skolem":

    > \f. (f:forall a. a -> a) 3
    1:5: Skolem variable s3 would escape its scope
    

    This case is more obscure and probably won't happen very much (especially once we fix Strange type checking error "Skolem variable would escape its scope" #2101), but it would still be nice to come up with a better error message that at least hints at what the problem might be.

@byorgey byorgey added Z-User Experience This issue seeks to make the game more enjoyable to play. C-Moderate Effort Should take a moderate amount of time to address. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. 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 Aug 9, 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-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. 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