hilti icon indicating copy to clipboard operation
hilti copied to clipboard

hilti-build: Function already declared error

Open dloss opened this issue 8 years ago • 0 comments

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
#  

dloss avatar Jan 10 '17 16:01 dloss