Repository navigation
cgen: ensure variable names do not conflict with builtin methods - #25178
Conversation
|
Connected to Huly®: V_0.6-24208 |
Run |
|
Looks like at worst about 30% slower. Not exactly amazing. I will think about a more efficient way to do these checks. |
|
Just as an idea. Can we prefix the builtin methods to avoid conflicts instead of doing checks? It shouldn't have such a performance impact, but the side effects are unknown |
|
Technically you could take the approach of prefixing built-in methods with something and output an error if the user tries naming a variable with that prefix. |
|
New impl is at worst around 4% slower than master, at lot better than before. |
|
You would need to cover a lot more cases than you think 🥲 |
471c4a8 to
6a8831f
Compare
|
Indeed there are a lot more cases of this than I expected (let me know if I am missing any obvious ones). Notably I added a lot more string, array and map methods. The second check I added doesn't appear to significantly affect performance over the one I had previously but there might be a better way to combine the checks? |
|
My newest implementation seems to have basically no performance impact. I'm covering a lot more cases (although likely still missing a few). |
|
Noticed that I broke autofree so I added handling for that too. Let me know if I'm missing testcases, otherwise the functionality is there. |
|
The code from the issue #25063 , still leads to a cgen error 🤔. V generated: VV_LOC void main__main(void) {
rune r = ((rune)(0));
Array_u8 _var_rune_bytes = rune_bytes(r);
{Array_u8 _ = rune_bytes;}
;
} |
|
On master, the generated code was: VV_LOC void main__main(void) {
rune r = ((rune)(0));
Array_u8 rune_bytes = rune_bytes(r);
{Array_u8 _ = rune_bytes;}
;
} |
|
Can't believe I missed that 🥲. I will add some extra tests. Edit: yes the fix was quite simple, I'm also adding a test for assignment. |
|
CI seems to be timing out on installing dependencies for some checks. Should I rerun? |
Yes. Github Actions runners are flaky in that way unfortunately :-| . |

See #25063.
This will probably cover most methods. Might be better to have a map of method names or something? Not sure how significant the performance hit of doing these checks is.