Skip to content

Math symbols in variable names should not allow variable assignment #24

@calculuschild

Description

@calculuschild

A variable with a name like this [ref-01] contains a math symbol (-) and so is actually treated as two variable names ref and 01.

However, math is only checked during variable expression when a $ prefix is attached. This can lead to weird shenanigans:

$[label-with+math]: url  // Assign variable

[label-with+math]     // Output as link

$[label-with+math]   // Fails because math is attempted

This will assign url to label-with+math and even express it as a link. However $[label-with+math] will not be able to access that variable because math is attempted first. For consistency, checking for math should be done in the variable assignment step as well.

Consideration

One thing to consider, is if we want to allow hyphenated var names, which has already come up naturally a few times. We could potentially restrict math to require spaces between operators which may be less confusing to users:

$[hyphenated-name] vs $[math - expression]

Test Cases

@ericscheid tested a range of other edge cases, some of which show related symptoms:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions