Skip to content

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

Description

@Nghi93
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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions