rsmmr / hilti

**NOTE**: This is outdated and no longer maintained. There's a new version at https://github.com/zeek/spicy.
Other
40 stars 22 forks source link

hilti-build: Function already declared error #27

Open dloss opened 7 years ago

dloss commented 7 years ago

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
#