Kind1 icon indicating copy to clipboard operation
Kind1 copied to clipboard

Compiler is not checking usage of erased arguments

Open elmattic opened this issue 4 years ago • 1 comments

Here is a minimal code sample to reproduce the error:

foo<size: Nat>(dummy: Word(size)): Word(size)
  Word.zero(size)

Main: IO(Unit)
  do IO {
    let x = 7
    let w = Word.from_bits(4, Nat.to_bits(x)) :: Word(4);
    let z = foo<_>(w)
    let nat = Nat.show(Word.to_nat<_>(z))
    IO.print("Hello, Formality! " | nat)
  }

Error:

Compilation error.
ReferenceError: _size$1 is not defined

elmattic avatar Feb 17 '21 23:02 elmattic

I am adding another sample code:

// TAKE

Nat.min.left_zero(a: Nat): 0 == Nat.min(a, 0)
  case a {
    zero: refl
    succ: refl
  }!

Word.take(size: Nat)(len: Nat, word: Word(size)): Word(Nat.min(size, len))
  case len {
    zero: Word.e :: rewrite x in Word(x) with Nat.min.left_zero(size)
    succ: case word {
      e: Word.e,
      o: Word.o!(Word.take<word.size>(len.pred, word.pred)),
      i: Word.i!(Word.take<word.size>(len.pred, word.pred))
    }!
  }!

// MAIN

Main: IO(Unit)
  do IO {
    let x = 7

    let w = Word.from_bits(4, Nat.to_bits(x)) :: Word(4);
    let z = Word.take<_>(1, w) // should be 1 :: Word(1)
    let nat = Nat.show(Word.to_nat<_>(z))

    IO.print("Hello World! " | nat)
  }

Error:

base$ kind Main --run
Compilation error.
ReferenceError: _word$size$5 is not defined

Note that putting parens doesn't help as a workaround.

elmattic avatar Feb 24 '21 17:02 elmattic

Closed because the repository now only contains the code for the Kind2 language.

algebraic-dev avatar Sep 21 '22 16:09 algebraic-dev