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

Use more descriptive English terms in type error messages #1313

Closed
byorgey opened this issue Jun 9, 2023 · 0 comments · Fixed by #1318
Closed

Use more descriptive English terms in type error messages #1313

byorgey opened this issue Jun 9, 2023 · 0 comments · Fixed by #1318
Assignees
Labels
C-Low Hanging Fruit Ideal issue for new contributors. 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-Feature A new feature to be added to the game.

Comments

@byorgey
Copy link
Member

byorgey commented Jun 9, 2023

This is a follow-up to #1308.

We should try harder to use more descriptive English terms in error messages, especially where unification variables or skolem variables occur in types. For example, instead of saying "expecting xyz to have type u3 -> u4 but it actually..." we could say something like "expecting xyz to be a function but it actually..." In other words, when printing type error messages, we should do some work to analyze the types involved and see if we can describe them in some way that doesn't involve a bunch of type variables, rather than simply pretty-printing them. At the very least we could replace unification variables with underscores or ellipses, as in "expecting xyz to have a type like (_ -> _) * _, but ..."

So, concretely, I propose the following. In the context of expecting xyz to ...

  • If a type has no variables, pretty-print it directly: have type `int -> text`
  • If a type consists of a top-level type constructor with variables in it, print it as a phrase: be a function
  • If a type is more complex but has variables in it, print it with underscores in place of the variables: have a type like `(_ -> _) * _`
@byorgey byorgey added Z-Feature A new feature to be added to the game. C-Low Hanging Fruit Ideal issue for new contributors. 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 Jun 9, 2023
@byorgey byorgey self-assigned this Jun 9, 2023
@mergify mergify bot closed this as completed in #1318 Jun 11, 2023
mergify bot pushed a commit that referenced this issue Jun 11, 2023
…ved (#1318)

Say things like "expecting `xyz` to be a function" instead of "expecting `xyz` to have type `u3 -> u4`".  Closes #1313.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Low Hanging Fruit Ideal issue for new contributors. 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-Feature A new feature to be added to the game.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant