spicy icon indicating copy to clipboard operation
spicy copied to clipboard

spicyc emits invalid HILTI code for method definitions

Open bbannier opened this issue 5 years ago • 0 comments

It looks like spicyc as of b74c8bf545d emits invalid HILTI code for method definitions, e.g., the following test fails:

# @TEST-EXEC: ${SPICYC} %INPUT -o foo1.hlt -p 
# @TEST-EXEC: ${HILTIC} foo1.hlt -o foo2.hlto -p
# @TEST-EXEC: diff -q foo1.hlt foo2.hlt

module foo;

type Bar = unit { };
$ btest -vd spicy.codegen.hlt
spicy.codegen.hlt ...
  > ${SPICYC} %INPUT -o foo1.hlt -p
  > ${HILTIC} foo1.hlt -o foo2.hlto -p
... spicy.codegen.hlt failed
  % '${HILTIC} foo1.hlt -o foo2.hlto -p' failed unexpectedly (exit code 1)
  % cat .stderr
  [error] foo1.hlt:30: syntax error, unexpected view, expecting function
  [error] hiltic: parse error

foo1.hlt:30 is

method extern method view<stream> foo::Bar::parse1(inout value_ref<stream> data, optional<view<stream>> cur = Null) &static {

This code is accepted when I remove the leading method extern.

Looking at the generated file I also see a suspicious method definition on line 15,

method method tuple<view<stream>, int<64>, iterator<stream>> foo::Bar::__parse_stage1(inout value_ref<stream> __data, copy view<stream> __cur, copy bool __trim, copy int<64> __lah, copy iterator<stream> __lahe) {

This still parses after removing the first occurrence of method on the line.

bbannier avatar Apr 06 '20 13:04 bbannier