Skip to content

NaN/undefined/Infinity should be matched as bindings rather than static values #317

Open
@gibson042

Description

@gibson042

(originally posted by @gibson042 in #293 (comment))

function pathological(x, undefined, NaN, Infinity) {
  return match (x) {
    when undefined: "undefined";
    when NaN: "NaN";
    when Infinity: "Infinity";
  }
}

Such bizarre bindings are honored elsewhere in the language (e.g., (NaN => [][NaN])("length") evaluates to 0 rather than undefined) and I believe discouraging the pattern via linters etc. is better than trumping explicit developer intent in match contexts where they are overridden.

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