Skip to content

Optional chaining symbol allowed overly permissively #3587

Description

@gwhitney

Describe the bug
The optional chaining operator is allowed to occur, and is then ignored, in many (but not all) cases between two terms that are being implicitly multiplied.

To Reproduce
In current develop, execute either math.evaluate('(3 + 4)?.(2)') or math.evaluate('add(3,4)?.(2)'). Either returns 14, but they both should issue a TypeError complaining that 7 is not a function. On the other hand, math.evaluate('7?.(2)') throws a syntax error. So this latter case correctly fails, but the behavior is possibly still problematic, in that JavaScript on the same expression 7?.(2) issues a TypeError complaining that 7 is not a function, suggesting that it is not a syntax error, but that the problem is rather that the number 7 cannot be called as a function.

Problems of this sort seem only to occur when the expression to the right is parenthesized. For example, math.evaluate('a = 7; a 2')) returns (a ResultSet of) 14 via implicit multiplication, but math.evaluate('a =7; a ?. 2') produces a SyntaxError that the ?. token is unexpected.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcategory:expressionsIssues about the expression parser, variable scoping etc.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions