sampsyo / bril

an educational compiler intermediate representation
https://capra.cs.cornell.edu/bril/
MIT License
557 stars 231 forks source link

brilirs: error on duplicate labels #331

Closed Pat-Lafon closed 2 months ago

Pat-Lafon commented 2 months ago

The following is kinda fun because brili terminates but brilirs does not(Whether one takes the first or last occurrence of a label).

@main{
    jmp .A;
    .A:ret;
    .A:jmp  .A;
}

While brilirs can mirror this behavior, it can also be "helpful" by returning an error when it detects multiple labels as the specification/users intention is ambiguous.

2 commits to clean up the function first

sampsyo commented 2 months ago

Awesome; seems great. I'm not sure if this restriction is in the spec, but it probably should be. 🤪