compilation error for inline-wasm with no return values
This program doesn't compile:
(use-modules (hoot inline-wasm))
(define (log msg x)
(%inline-wasm
'(func (param $str (ref string)) (param $x (ref eq))
(call $debug-str-scm (local.get $str) (local.get $x)))
msg x))
(call-with-values (lambda () (log "hello" 42))
(lambda vals vals))
The error we get:
Backtrace:
In language/tree-il/compile-cps.scm:
2092:9 19 (convert #<transient-intmap 0-5> _ 1 #<hash-table 7f75ca71e6a0 1588/3517>)
2104:10 18 (lp #<transient-intmap 0-5> _ _ (#<tree-il (call (lexical char-set-union #{char-set-union 12865}#) (lexical …>))
2104:10 17 (lp #<transient-intmap 0-5> _ _ (#<tree-il (call (lexical string->char-set #{string->char-set 12867}#) (cons…>))
2104:10 16 (lp #<transient-intmap 0-5> _ _ (#<tree-il (call (lexical string->char-set #{string->char-set 12867}#) (cons…>))
2104:10 15 (lp #<transient-intmap 0-5> _ _ (#<tree-il (call (lexical char-set-union #{char-set-union 12865}#) (lexical …>))
2104:10 14 (lp #<transient-intmap 0-5> _ _ (#<tree-il (call (lexical list->char-set #{list->char-set 12855}#) (const (#…>))
2092:9 13 (convert #<transient-intmap 0-5> _ 1 #<hash-table 7f75ca71e6a0 1588/3517>)
2092:9 12 (convert #<transient-intmap 0-5> _ 1 #<hash-table 7f75ca71e6a0 1588/3517>)
2092:9 11 (convert #<transient-intmap 0-5> _ 1 #<hash-table 7f75ca71e6a0 1588/3517>)
2092:9 10 (convert #<transient-intmap 0-5> _ 1 #<hash-table 7f75ca71e6a0 1588/3517>)
2134:11 9 (convert #<transient-intmap 0-5> _ 1 #<hash-table 7f75ca71e6a0 1588/3517>)
2134:11 8 (convert #<transient-intmap 0-5> _ 1 #<hash-table 7f75ca71e6a0 1588/3517>)
2134:11 7 (convert #<transient-intmap 0-5> _ 1 #<hash-table 7f75ca71e6a0 1588/3517>)
2134:11 6 (convert #<transient-intmap 0-5> _ 1 #<hash-table 7f75ca71e6a0 1588/3517>)
2134:11 5 (convert #<transient-intmap 0-5> _ 1 #<hash-table 7f75ca71e6a0 1588/3517>)
2092:9 4 (convert #<transient-intmap 0-5> _ 1 #<hash-table 7f75ca71e6a0 1588/3517>)
1639:7 3 (convert-arg #<transient-intmap 0-5> #<tree-il (const "hello")> #<procedure 7f75ca037fc0 at language/tree-il/…>)
1639:7 2 (convert-arg #<transient-intmap 0-5> #<tree-il (const 42)> #<procedure 7f75ca037f90 at language/tree-il/compi…>)
In hoot/inline-wasm.scm:
325:15 1 (_ #<transient-intmap 0-5> (1623 1624))
233:7 0 (n-valued-continuation #<transient-intmap 0-5> _ 0 _)
hoot/inline-wasm.scm:233:7: In procedure n-valued-continuation:
unexpected continuation for n-valued result 0
From what I can tell, the continuation from inline wasm requires 1 value. I'm not sure why, though, since we are accepting any number of return values in the call-with-values
consumer.
Notably, this program works fine:
(use-modules (hoot inline-wasm))
(define (log msg x)
(%inline-wasm
'(func (param $str (ref string)) (param $x (ref eq))
(call $debug-str-scm (local.get $str) (local.get $x)))
msg x))
(call-with-values (lambda () (log "hello" 42))
(lambda () 61))