Skip to content

Using variable 'limit_max' causes error: Unexpected token '.' #4

@idbrii

Description

@idbrii

The automatic Math. prefix doesn't search for whole words so if your javascript code has any tokens that contain names in Math, they fail with a confusing error message:

// Error: Unexpected token '.'
function clamp(num, limit_min, limit_max) {
  return num <= limit_min ? limit_min : num >= limit_max ? limit_max : num;
}

// No error after renaming to avoid 'max' and 'min'
function clamp(num, limit_in, limit_ax) {
  return num <= limit_in ? limit_in : num >= limit_ax ? limit_ax : num;
}

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