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

Error message from argument mismatch #106

Closed
rossberg opened this issue Jul 11, 2024 · 1 comment
Closed

Error message from argument mismatch #106

rossberg opened this issue Jul 11, 2024 · 1 comment
Assignees

Comments

@rossberg
Copy link
Collaborator

While working on #105 I got this error:

: interpreter error: Args number mismatch for algorithm CVTOP (interpreting CaseV(CVTOP, [CaseV(I64, []), CaseV(I64, []), CaseV(EXTEND, [CaseV(S, [])])]))

I was confused for a while, since I had adapted all rules and also all conversion functions hard-coded in convert.ml. I was not able to tell what "algorithm CVTOP" was referring to concretely with no source position. It took me a while to notice that this was due to me not having changed the 1.0/2.0 specs accordingly, which now were inconsistent with convert.ml.

Could the above message be improved to give a source position and use the actual source-level identifier of the corresponding definition?

@f52985
Copy link
Collaborator

f52985 commented Jul 12, 2024

The "algorithm CVTOP" is an automatically generated psuedo-code from the two reduction rules for CVTOP,

;; spec/wasm-2.0/8-reduction.watsup:201.1-207.50
rule Step_pure/cvtop-val:
  (CONST nt_1 c_1) (CVTOP nt_2 nt_1 cvtop sx?)  ~>  (CONST nt_2 c)
  -- if $cvtop(nt_1, nt_2, cvtop, sx?, c_1) = c  ;; TODO

rule Step_pure/cvtop-trap:
  (CONST nt_1 c_1) (CVTOP nt_2 nt_1 cvtop sx?)  ~>  TRAP
  -- if $cvtop(nt_1, nt_2, cvtop, sx?, c_1) = eps  ;; TODO

-->

execution_of_CVTOP nt_2 nt_1 cvtop sx?
1. Assert: Due to validation, a value of value type nt_1 is on the top of the stack.
2. Pop the value (nt_1.CONST c_1) from the stack.
3. If (|$cvtop(nt_1, nt_2, cvtop, sx?, c_1)| is 1), then:
  a. Let [c] be $cvtop(nt_1, nt_2, cvtop, sx?, c_1).
  b. Push the value (nt_2.CONST c) to the stack.
4. If ($cvtop(nt_1, nt_2, cvtop, sx?, c_1) is []), then:
  a. Trap.

and I think that the error message that explicitly denotes "which part of the spec files is converted in to the algorithm in interest", as in below message, would be sufficient for the user to understand the situation better.

: interpreter error: Expected 4 arguments for the algorithm `CVTOP` (spec/wasm-2.0/8-reduction.watsup:201.1-207.50) but 3 arguments are given (interpreting CaseV(CVTOP, [CaseV(I64, []), CaseV(I64, []), CaseV(EXTEND, [CaseV(S, [])])]))

It's included in the PR #107.

Let me know if it looks good!

@f52985 f52985 closed this as completed Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants