Ignore main functions inside block comments - #1250
Conversation
|
Thanks for the PR! I'm curious: what level of computer assistance did you have in creating this code? It's not super common for people to write out a parser from scratch. I'm really quite torn on whether or not this is a good path to continue on, however. This code splits up the string character-by-character, does the logic, then creates the string again; that all feels overly wasteful. A quick benchmark using a 47K Rust file I have lying around shows that this code now takes ~2.8ms from the previous ~1.9ms. There's also a giant blob of new code to maintain. On top of that, it's all ultimately supporting regex hacks. I whipped together a quick prototype of using tree-sitter compiled to Wasm, and that's even slower (~5.8ms), but at least that should be a very robust solution and could be used for multiple purposes. |
|
I used an AI coding assistant for the first draft, then reviewed and tested it locally. You were right that the scanner was too much for this. I replaced it with a small regex-based pass that preserves line comments, normal strings, and raw strings. On a synthetic 47 KB input it took about 0.15 ms. The selector tests, lint, formatting, and type checking pass. |
|
See #1263 for my alternate solution. |
Block-commented main functions no longer select Run automatically.
This removes multiline and unclosed block comments before applying the existing main-function check. It leaves comment markers inside line comments, normal strings, and raw strings alone.
Fixes #1167