Skip to content

function name should be included in the error message when not bound in call #416

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

Open
He-Pin opened this issue May 27, 2025 · 2 comments
Open

Comments

@He-Pin
Copy link
Contributor

He-Pin commented May 27, 2025

In #39, @eregon report:

#39 (comment)

I think he is right here, and I think the function name should be included in the error message, eg:

    test("unboundParam") {
      val ex = intercept[Exception] {
        eval(
          """local newParams(x, y) = {
            |  x: x,
            |  y: y,
            |};
            |
            |local params = newParams("a");
            |
            |params.y
            |
        """.stripMargin,
          useNewEvaluator = useNewEvaluator
        )
      }

      assert(ex.getMessage.contains("Function parameter y not bound in call"))
    }

can be Function parameter y not bound in call to function newParams

@eregon
Copy link

eregon commented May 27, 2025

That would be helpful, but also mentioning not enough/too many arguments would be the clearest I believe.
Because "parameter y not bound" sounds very vague at least to me, like some variable hasn't a value yet because lazy semantics or something.
In general I would say this error is not about binding of variables, it's about not enough/too many arguments.

For example this is what Ruby does in such a case:

$ ruby -e 'def m(a,b) = 0; m(1)'       
-e:1:in `m': wrong number of arguments (given 1, expected 2) (ArgumentError)

It's very clear, compared to "parameter b not bound in call".

@He-Pin
Copy link
Contributor Author

He-Pin commented May 27, 2025

@eregon Nice, would you like to contribute this a PR?

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