0xPolygonMiden / miden-vm

STARK-based virtual machine
MIT License
612 stars 150 forks source link

Forbid reserved words in procedures names #1293

Open hackaugusto opened 3 months ago

hackaugusto commented 3 months ago

This assembles and runs:

proc.exec
    push.1
end

begin
    exec.exec
end

It works because the namespaces are no shared, but it is odd that this works. To avoid confusion I think we should forbid this.

bitwalker commented 3 months ago

The parser in #1277 makes it easy for us to whitelist/blacklist identifiers that can be used "bare" (i.e. without quotes). Right now, this behavior is still allowed, but we can remove items from the Opcode non-terminal that we do not want to allow in identifiers. An argument could be made that none of them should be allowed as identifiers, but I didn't want to break any code that relied on this being allowed.

Now that quoted identifiers are a thing, I think blacklisting any opcodes as valid identifiers and requiring them to be quoted if you want to use those names anyway, is probably the right way to go here. I could go either way on whether or not we should allow them bare when invoking call/exec/etc. when there is a procedure by that name, but certainly requiring them to be quoted when defining the procedure seems like a good idea to me.