Skip to content

variable named E blocks .-operators #3422

@gwhitney

Description

@gwhitney

Describe the bug
If a variable happens to be named E, then you cannot implicitly multiply it by a constant and then apply an operator that starts with . unless you insert whitespace.

To Reproduce

const eval = math.evaluate
const scope = {E: [1, 2]}
eval('3E', scope)  // [3, 6]
eval('E.*2', scope)  // [2, 4]
eval('3E.*2', scope)  // SyntaxError: Digit expected, got "." (char 2)
eval('3E .*2', scope)  // [6, 12]

Discussion
I understand that we don't want fractional exponential notation e.g. 3E.7 but there does not seem to be any reason to disallow a bona fide operator that happens to start with . after an expression that happens to end in E or e.

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