Stream: t-compiler

Topic: check_attr vs codegen_fn_attrs


Hanna Kruppe (Mar 26 2020 at 10:14, on Zulip):

Currently, the validation of some attributes is spread across two parts of the code: the check_attrs pass and the codegen_fn_attrs query. To me there is no clear principle behind what kind of check goes where. The split also causes other problems: some errors are only emitted if codegen_fn_attrs is called on the function/method/closure that has an invalid attribute, and check_attrs tries to call it for that purpose but it's rather incomplete. This leads to bugs such as #70307 and mysterious test failures (now resolved) in #69274.

I feel like there should be a more robust and unified way to perform attribute validation, but I'm not sure what it looks like and would appreciate ideas. Some of the "validation" in codegen_fn_attrs is clearly appropriate there (in particular, the parsing of the values passed to attributes), but I don't see a principled way to ensure it runs before codegen on every item and expression. OTOH, we can't really move the "does this attribute even make sense on this kind of item/expression" checks out of check_attrs because codegen_fn_attrs only applies to function-like things.

Last update: May 29 2020 at 17:40UTC