Open gysddn opened 1 month ago
@josh11b I'm trying to figure out how to review this. Looking at the generics design, I see examples of its use, but I'm having trouble finding what the full syntax is. Is the syntax in the design somewhere that I'm missing? Some of the examples include
where
, does this overlap with thewhere
parsing you've been looking at?
The argument to require
is supposed to match the argument to where
, which I recently was working on -- see #4075 . The arguments are described in https://github.com/carbon-language/carbon-lang/blob/trunk/docs/design/generics/details.md#where-constraints -- though the description is spread out across that whole section, without a short summary of just the syntax.
One thing to note, though, that in discussions we've decided that the argument to a where
clause is not an expression, and so it has its own distinct interpretation of symbols like ==
that appear in ordinary expressions.
The argument to
require
is supposed to match the argument towhere
, which I recently was working on -- see #4075 . The arguments are described in https://github.com/carbon-language/carbon-lang/blob/trunk/docs/design/generics/details.md#where-constraints -- though the description is spread out across that whole section, without a short summary of just the syntax.
So to be sure I understand correctly, require
actually has a single argument, and that argument is the same as an argument to where
? i.e., the impls
just happens to be in all the examples?
(if that understanding is correct, probably this change should be reverted since josh11b is already working on where
syntax, and this change isn't going to provide the right support)
The argument to
require
is supposed to match the argument towhere
, which I recently was working on -- see #4075 . The arguments are described in https://github.com/carbon-language/carbon-lang/blob/trunk/docs/design/generics/details.md#where-constraints -- though the description is spread out across that whole section, without a short summary of just the syntax.So to be sure I understand correctly,
require
actually has a single argument, and that argument is the same as an argument towhere
? i.e., theimpls
just happens to be in all the examples?(if that understanding is correct, probably this change should be reverted since josh11b is already working on
where
syntax, and this change isn't going to provide the right support)
https://github.com/carbon-language/carbon-lang/blob/trunk/proposals/p2760.md#proposal
For now, only the
impls
forms ofwhere
clauses are permitted afterrequire
.
Eventually my expectation is that we would accept any kind of where
clause after require
when parsing, and then add restrictions in the check stage; but for now it is totally fine to only accept impls
after require
in parse.
So to be sure I understand correctly,
require
actually has a single argument, and that argument is the same as an argument towhere
? i.e., theimpls
just happens to be in all the examples?
Yeah, I didn't really realize this while making these changes. If the syntax will be provided by @josh11b changes, then I can update this PR or just make another one.
To be sure we're all on the same page:
require <expr> impls <expr>;
.
Added new nodes to the parse tree to handle require declarations
Require
is a new bracketed parse node with the following structure:Require -Impls (New node for
expr impls expr
statements)Two test cases added for the usage in the interfaces.