diku-dk / futhark

:boom::computer::boom: A data-parallel functional programming language
http://futhark-lang.org
ISC License
2.4k stars 167 forks source link

`size` is not bound to a value #1992

Closed WilliamDue closed 1 year ago

WilliamDue commented 1 year ago

How to replicate the error

I have a Futhark source file err.fut containing the following code.

module type data = {
  val size : i64
  val const : u8 -> [size]u8
}

module make(G: data) = {
  def id (t : [][G.size]u8) : [][G.size]u8 = t
  def const_map (str : []u8) : [][G.size]u8 = map G.const str
}

module thing = make {
  def size : i64 = 3
  def const (_ : u8) : [size]u8 = sized size [1, 2, 3]
}

def f str = thing.const_map str |> thing.id

When I enter the REPL futhark repl err.fut and do f [1, 2, 3] as an example I get the following error.

Internal compiler error (unhandled IO exception).
Please report this at https://github.com/diku-dk/futhark/issues
size is not bound to a value.
-> #0  [0]> :1:1-8

CallStack (from HasCallStack):
  error, called at src/Language/Futhark/Interpreter.hs:654:7 in futhark-0.26.0-8TxRAg15nJlFGbXOt63c7o:Language.Futhark.Interpreter

Version

Futhark 0.26.0 (prerelease - include info below when reporting bugs)
git: 4c7097f183ac8105d4579bef4127e9dd2cfbfed7
athas commented 1 year ago

It's an interpreter bug; probably when it looks up qualified names in sizes.

athas commented 1 year ago

Slightly simplified.

module type data = {
  val size : i64
  val const : u8 -> [size]u8
}

module make(G: data) = {
  def const_map (str : []u8) : [][G.size]u8 = map G.const str
}

module thing = make {
  def size : i64 = 3
  def const (_ : u8) : [size]u8 = sized size [1, 2, 3]
}

entry main str = id (thing.const_map str)

-- ==
-- input { [1u8,2u8,3u8] }