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

Applying a function to too few arguments produces a difficult to understand error #1765

Open
bboston7 opened this issue Nov 23, 2022 · 2 comments
Assignees
Labels
documentation debt Documentation tasks previously deferred, postponed, etc.; technical debt in documentation documentation Issues involving documentation topics: error-messages Issues involving the messages SAW produces on error type: bug Issues reporting bugs or unexpected/unwanted behavior usability An issue that impedes efficient understanding and use
Milestone

Comments

@bboston7
Copy link
Contributor

Assume a helper function:

let pointer_to_fresh (type : LLVMType) (name : String) = do { ... }

If a developer forgets to pass in the name argument, they get an error like:

[23:14:52.267] /workspaces/exercises/functional-correctness/swap/solution/solution.saw:87:27-99:2: Type Mismatch, expected: t.1 (t.2, t.3) but got: String -> LLVMSetup (Term, SetupValue)
 at "swap_array_spec" (/workspaces/exercises/functional-correctness/swap/solution/solution.saw:87:5-87:20)
Type constructors mismatch. Expected: <Block> but got (->) at "swap_array_spec" (/workspaces/exercises/functional-correctness/swap/solution/solution.saw:87:5-87:20)

In my experience, new users have no idea what this is trying to say. Some specific problems with it:

  1. The error buries the lede. The important part is Type Mismatch, expected: t.1 (t.2, t.3) but got: String -> LLVMSetup (Term, SetupValue) which communicates that the proof writer failed to provide a String argument. Unfortunately, this error message is attached to many lines of SAW source (87:27-99:2), while the somewhat useless Type constructors mismatch is attached to a much narrower code range leading new users to focus on that error.
  2. Learners do not know what any of these types mean. In some cases, they cannot even look it up. LLVMSetup doesn't appear at all in the SAW manual. Neither does <Block>.
  3. The line numbers are misleading. In the example that produced this error, the pointer_to_fresh call with a missing argument is on line 88. However, the error directs users to lines 87-99 (a broad range that hardly helps to narrow things down) and line 87 (the declaration for the function that contains the bad pointer_to_fresh call). Learners might be able to fix these errors more easily if they're pointed to the right line.

When applying a function to too many arguments, you get the helpful suggestion:

(maybe a function is applied to too many arguments?)

It would be great to do the same when applying a function to too few arguments.

@bboston7 bboston7 added topics: error-messages Issues involving the messages SAW produces on error usability An issue that impedes efficient understanding and use labels Nov 23, 2022
@sauclovian-g
Copy link
Contributor

#2046 will help with this some, but not really fix it properly.

@sauclovian-g
Copy link
Contributor

The position lossage was fixed in #2076, but the problems with Block remain, and something needs to be done about the docs as well.

@sauclovian-g sauclovian-g added documentation Issues involving documentation documentation debt Documentation tasks previously deferred, postponed, etc.; technical debt in documentation labels Nov 5, 2024
@sauclovian-g sauclovian-g added this to the 2024T3 milestone Nov 5, 2024
@sauclovian-g sauclovian-g self-assigned this Nov 5, 2024
@sauclovian-g sauclovian-g added the type: bug Issues reporting bugs or unexpected/unwanted behavior label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation debt Documentation tasks previously deferred, postponed, etc.; technical debt in documentation documentation Issues involving documentation topics: error-messages Issues involving the messages SAW produces on error type: bug Issues reporting bugs or unexpected/unwanted behavior usability An issue that impedes efficient understanding and use
Projects
None yet
Development

No branches or pull requests

2 participants