hilti
hilti copied to clipboard
hilti-build: Function already declared error
Declaring a function after the unit that it's used in results in a compilation error:
# cat mini.spicy
module Mini;
export type MyUnit = unit {
field : bytes &convert=myfunc($$);
};
bytes myfunc(b: bytes) {
return b;
}
# hilti-build -o mini mini.spicy
>>> ref<bytes> myfunc__Vjw(ref<bytes> b, <Unresolved 'SpicyHilti::UserCookie'> __cookie) {
return.result b }
mini.hb689.tmp.hlt:532-532: error, ID myfunc__Vjw already declared [pass::hilti::ScopeBuilder]
mini.hb689.tmp.hlt: Aborting due to verification error.
error running hiltic, aborting
Declaring the function before the unit results in a successful compilation:
# cat mini-reordered.spicy
module Mini;
bytes myfunc(b: bytes) {
return b;
}
export type MyUnit = unit {
field : bytes &convert=myfunc($$);
};
# hilti-build -o mini-reordered mini-reordered.spicy
#