zeek / spicy

C++ parser generator for dissecting protocols & files.
https://docs.zeek.org/projects/spicy
Other
246 stars 35 forks source link

Cannot initialize a `const` with the result of a function call #1745

Closed bbannier closed 3 months ago

bbannier commented 4 months ago

As of spicyc v1.11.0-dev.168 (b8776965e) it seems impossible to initialize a const with the result of a function call,

module foo;

function bar(): uint16 {
    return 4711;
}

# error: use of undeclared identifier 'bar'
# ||     const ::hilti::rt::integer::safe<uint16_t> xs = bar();
# ||                                                     ^
const xs = bar();

We should either allow this, or reject it explicitly.