component-model icon indicating copy to clipboard operation
component-model copied to clipboard

Inconsistent semi colons on wit file Include's when renaming via `with`

Open jsturtevant opened this issue 8 months ago • 5 comments

This parses:

world union-my-world-a {
    include world-one;
    include world-two with { a as b }
}

but if I add a ; to the with it fails

world union-my-world-a {
    include world-one;
    include world-two with { a as b };
}

Is that intentional or is there a reason for that?

jsturtevant avatar May 16 '25 22:05 jsturtevant

I expect this is due to the general rule of not requiring a ; after }. But in this case, I think you're right that it seems more regular to have the ; at the end of every include, even with with.

lukewagner avatar May 19 '25 16:05 lukewagner

Yeah this was originally not required due to the general rules of "does this end with } or not". I'm personally ambivalent on which way to go here, but another thing to point out is import x: interface { ... } is somewhat similar to import x; where one requires a semicolon and one doesn't. Additionally there's resource x; and resource x { .. }

alexcrichton avatar May 20 '25 14:05 alexcrichton

Ok makes sense, I don't have a strong opinion here either. It was surprising but not a huge issue.

jsturtevant avatar May 20 '25 15:05 jsturtevant

Since with { ... } is more of a clause/add-on to the base include statement (as opposed to the entirety of the definition, as in the case of resource r { ... }/interface i { ... }), and hypothetically there could be other kinds of clauses added in the future, perhaps going before or after with { ... } clauses, it might be good to conservatively require the terminating ; of include statements always (or at least allowing it for now and deprecating the absence of ;).

lukewagner avatar May 20 '25 16:05 lukewagner

That's true yeah, and I'm certainly not oppose to requiring a ; in the long run. I think I basically amount to not having much of a preference. I do strongly prefer, however, that ; is either required to disallowed, basically I don't want to be in a situation where it's optional. (I realize that's not being proposed but wanted to write this down nevertheless)

alexcrichton avatar May 23 '25 14:05 alexcrichton