acton icon indicating copy to clipboard operation
acton copied to clipboard

Mangle variable names to avoid collisions / conflict with stdout / stderr

Open plajjan opened this issue 1 year ago • 1 comments

It seems there are some names that are best avoided as variable / argument names on a C-level:

  • stdout / stderr seem to be reserved on platforms like Windows and in Musl libc
  • ERROR appears to be some macro on Windows, our logging.ERROR constants conflicts

I think it's best to avoid these names.

Currently, we generate C code that uses argument names straight from Acton, so

actor blargh():
    var stdout = b""

will fail to compile on Musl.

What to do? Mangle names? Maybe we just add some special cases for reserved names?

@nordlander WDYT?

plajjan avatar Mar 15 '24 14:03 plajjan

@nordlander do you think we could add a list of reserved names and if we see such a name, we add some prefix to it to avoid the reserved name? We'd obviously have to look for the prefix as well so nothing collides with our prefixed name.

plajjan avatar Apr 14 '24 08:04 plajjan