Troupe
Troupe copied to clipboard
Library cannot use named functions for values
Consider the following (minimised) version of the unit testing library I've been writing
(** FILE: lib/Unit.trp *)
let
(*--- Pretty Printing ---*)
fun yellow s = "\x1b[33m" ^ s ^ "\x1b[0m"
val testStr = yellow "[ TEST ] "
(*--- Test Creation ---*)
fun foo _ = 42
(*--- Module ---*)
val Unit = {
foo = foo
}
in [ ("Unit", Unit) ]
end
imported as follows
(** FILE: test/lib/Unit.trp *)
import Unit
let val _ = Unit.foo
in 0
end
At runtime, the import breaks with the following error
file:///troupe/rt/built/loadLibsAsync.mjs:41
let table = libinstance.export({ __dataLevel: levels.BOT }).val.toArray();
^
TypeError: Cannot read properties of undefined (reading 'toArray')
at loadLibsAsync (file:///home/soelvsten/git/postdoc/troupe/rt/built/loadLibsAsync.mjs:41:72)
at async UserRuntimeZero.linkLibs (file:///home/soelvsten/git/postdoc/troupe/rt/built/builtins/UserRuntimeZero.mjs:228:9)
at async start (file:///home/soelvsten/git/postdoc/troupe/rt/built/runtimeMonitored.mjs:397:5)
As far as we can tell, the library is compiled into a closure rather than as a list exported values.