8000 A literal pattern or `==` with a value of an unrelated type passes the checker · Issue #773 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

A literal pattern or == with a value of an unrelated type passes the checker #773

Open

Description

@akoskovacs

A String literal arm in a match on an Integer, and == between an Integer and a String, are both accepted, though neither can ever be true.

let name(n: Integer) -> String do
  match n do
    "one" => "1"
    _ => "other"
  end
end

main do
  IO.printLine(name(1))
  IO.printLine(1 == "1")
end

kex -C says No errors found., and both backends print other and false.

The same mistakes with optionals and constructors are rejected: KEXET-0494 for String? == String, and KEXET-0113 for another type's constructor in a pattern. Expected the same for literals and for == between unrelated types.

Seen on kex 0.4.0-rc.4 built from main at 371bbdf, and on 5773911. Found while writing explanations for oops.kex.run.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0