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

parse error does not show the function causing the error #264

Open
Nghi93 opened this issue Feb 28, 2022 · 0 comments
Open

parse error does not show the function causing the error #264

Nghi93 opened this issue Feb 28, 2022 · 0 comments

Comments

@Nghi93
Copy link

Nghi93 commented Feb 28, 2022

calculator = Dentaku::Calculator.new
calculator.add_function(:custom, :integer, lambda do
  1
end)

calculator.ast("CUSTOM(1,2)") #=> Dentaku::ParseError (Dentaku::AST::Function::Custom has too many operands)
calculator.ast("CUSTOM(1,2)") #=> Dentaku::ParseError (Dentaku::AST::Function::Custom has too many operands)

calculator = Dentaku::Calculator.new
calculator.add_function(:custom, :integer, lambda do
  1
end)

calculator.ast("CUSTOM(1,2)") #=> Dentaku::ParseError (#<Class:0x00007fbc1a57ecb0> has too many operands)

Probably some caching issue? The method class is not shown but instead an anonymous class.
One quick fix would be to change the fail! method but I think that's not the root cause:

    def fail!(reason, **meta)
      message =
        case reason
          ....
        when :too_many_operands
          "#{meta.fetch(:operator).name} has too many operands"
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

1 participant