FFFF Type arguments are not arity-checked · Issue #648 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

Type arguments are not arity-checked #648

Closed

Description

@akoskovacs

A generic type can be written with the wrong number of type arguments, or with none, and the checker accepts it.

Repro

let first(r: Result) -> Integer = 1
let f(x: Optional<Integer, String, Bool>) -> Integer = 2

main do
  IO.printLine("${first(Ok(1))}")
end

Actual: accepted; prints 1.

Expected:

  • Optional<Integer, String, Bool>: an error, Optional takes one type argument.
  • Bare Result in a signature: an error, or a documented meaning. Today it silently matches every Result<A, E>.

Cause

Type arguments are never counted against the declaration. In argMatchesParam, a named type with no arguments on either side matches any instantiation of that name (src/semantic/typechecker_expr.cxx:3694-3700). That rule is used on purpose for make Range style receivers, so the bare form probably has to stay legal there and be rejected elsewhere.

Reproduced on kex 0.4.0-rc.3 (266b7a60) with the type checker on.

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

    BugSomething isn't workingConfirmed IssueBug is reproduced on the current development versionTypechecker

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0