parser: check invalid struct name in struct_init()#26093
parser: check invalid struct name in struct_init()#26093spytheman merged 2 commits intovlang:masterfrom
Conversation
spytheman
left a comment
There was a problem hiding this comment.
Excellent work.
Did you find out the root reason, that the previous message (from the issue) used the wrong .v file?
Can it happen in other cases too, that are not reported yet?
(it took a lot of time and dialogs on Discord to diagnose and isolate it)
_ := http.Response{header: http.new_header{} }Here, a Lines 1789 to 1801 in 0aa3e2d
Lines 552 to 556 in 0aa3e2d
mut h := new_header()It now assumes Lines 1715 to 1727 in 0aa3e2d The root cause of this bug is that the parser incorrectly registers |
|
I'm not satisfied with this patch because it introduces excessive checks within the |
|
That is one option indeed, that could make such messages a lot less confusing. Another (perhaps complementary, and not alternative) is to somehow prevent the registration of types for other modules in the parser, based on incomplete code, and leaving the type checking and matching to the checker stage, where the type information is more complete (and can be analyzed in topological order, so that |
|
Running Ideally this should not matter, if the parser does not try to do type checking, and just produces a concrete AST from each file (which could have other benefits like future parallelization) , but unfortunately currently the parser does use its ast.table for checks, and not just registrations, so it is sensitive to ordering issues :-| . |
|
Making the parser only parse, and moving the checking for correctness to the checker, makes logical sense. V has too much "bleed-through" between stages... parser does checks, cgen creates methods, etc. Cleaning all that up so that the various stages only do what they are supposed to do should make V much easier to maintain. |
Yes, I think the parser should not register type. |
|
I am merging the PR as it is for now, since it does prevent a weirder situation, with a minimal change. I am also glad of the discussion that followed, and that we all understand what the ideal for the parser should be, and why it would be useful to move in that direction. Thank you 🙇🏻♂️ . |
Fix issue #26030
check invalid struct name in
struct_init().