8000 Checker accepts Option<T> where T is expected (let annotation and call args) · Issue #611 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

Checker accepts Option<T> where T is expected (let annotation and call args) #611

Closed

Description

@akoskovacs
8000

All three pass `kex -C` with `No errors found` (`kex 0.4.0-rc.3 (78af651)`):

main do
  let x: Integer = Just(0)   # let annotation, Just
  IO.printLine(x)
end
main do
  let x: Integer = None       # let annotation, None
  IO.printLine(x)
end
let pick(n: Integer) -> Integer = n

main do
  IO.printLine(pick(Just(5))) # call argument
end

Contrast: `let x: Integer = "hi"` correctly reports `error: Type mismatch: expected Integer, got String`, so annotations are enforced in general — `Option` specifically seems compatible with `T`.

Runtime consequence: the mistyped value flows through, e.g. `pair[0] + pair[1]` on `Option` operands reaches the backends (walker: `runtime error: Cannot add Optional and Optional` with a location; BEAM: a bare `Internal error: function_clause`). Found while drafting Rosetta Code entries.

Activity

  1. akoskovacs commented on Nov 12, 2026

    @akoskovacs
    CollaboratorAuthor

    Another variant, still present on kex 0.4.0-rc.3 (266b7a60): an optional variable passed as a call argument.

    let double(n: Integer) -> Integer = n * 2
    
    main do
      let maybe: Integer? = None
      IO.printLine("${double(maybe)}")
    end
    

    Accepted; fails at run time with badarith.

    The cause is a branch in argMatchesParam that unwraps an optional argument and retries against the bare parameter (src/semantic/typechecker_expr.cxx:3519-3521).

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