rems-project / sail

Sail architecture definition language
Other
618 stars 112 forks source link

Clashing function and enum #405

Open algr opened 11 months ago

algr commented 11 months ago

Do function names and enum constants live in separate namespaces, and should this be legal?

function foo(): unit -> int = 1
enum E = { foo }

Sail accepts it, but the C back end uses zfoo for both names, so the C won't compile.

Alasdair commented 11 months ago

Currently they are namespaced separately in Sail, but we could probably be stricter. Currently we have types, functions+union constructors, and regular identifiers (enum constants, variable names) separate.

In practice I think everyone Uppercases enum constants and lower_snake_cases functions, so we haven't run into this. It might be better to keep the C output the same by making the namespacing stricter rather than adding a prefix or something.