Update the set of annotations in later compiler passes
Currently the set of attributes is set by low_add_identifier()
, which is typically only called in the first pass of the compiler. This means that it may get called with placeholder objects.
This can be observed by the following (LysLysKOM 26239366):
// -*- mode: Pike; c-basic-offset: 4; -*-
class Anno(string label) {
inherit Pike.Annotation;
@constant;
protected string _sprintf(int c) {
return sprintf("%O(%O)", object_program(this), label);
}
}
@Anno("foobar"):
void some_func() { }
int main(int argc, array(string) argv)
{
werror("Annotations: %O\n", mkmapping(indices(this), annotations(this)));
}
Which currently outputs:
Annotations: ([ /* 3 elements */
"Anno": 0,
"main": 0,
"some_func": (< /* 1 element */
/main()->Anno(0)
>)
])
Note the Anno(0)
rather than the expected Anno("foobar")
.
Thanks to @Rosuav for the example.