Skip to content

Unknown generic id for type Var #1201

@KtorZ

Description

@KtorZ

What Git revision are you using?

v1.1.19

What operating system are you using, and which version?

  • Linux / Ubuntu
  • Linux / Other
  • macOS
  • Windows

Describe what the problem is?

Here's a somewhat contrived aiken snippet:

type Maybe<a> =
  fn(fn() -> _, fn(a) -> _) -> _

pub fn just(a: a) -> Maybe<a> {
  fn(_, when_a) { when_a(a) }
}

pub fn nothing() -> Maybe<a> {
  fn(when_nothing, _) { when_nothing() }
}

pub fn match(
  self: Maybe<a>,
  when_nothing: fn() -> result,
  when_just: fn(a) -> result,
) -> result {
  self(when_nothing, when_just)
}

test maybe() {
  let n <- match(just(42), fn() { fail })
  n == 42
}

This crashes the compiler with:

 crates/aiken-lang/src/tipo.rs:869:17

       Unknown generic id 1447 for type Var { tipo: RefCell { value: Generic { id: 1447 } }, alias: None } in mono_types {
       1441: App {
           public: true,
           contains_opaque: false,
           module: "",
           name: "Int",
           args: [],
           alias: None,
       },
       1416: App {
           public: true,
           contains_opaque: false,
           module: "",
           name: "Bool",
           args: [],
           alias: None,
       },
       1556: App {
           public: true,
           contains_opaque: false,
           module: "",
           name: "Bool",
           args: [],
           alias: None,
       },
   }

What should be the expected behavior?

That should either generate a user-level error; or succeed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    🪣 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions