-
Notifications
You must be signed in to change notification settings - Fork 446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lexer bug #108
Comments
The example can be made even more devious by changing
|
The second problem isn't any harder than the first one. |
I see a few options:
-N |
The problematic case that's really hard to parse is
We can disallow redeclaring types in this one case (allowing redeclaring types as type parameters in other contexts) with a fairly small grammar change; this case is problematic as you don't know that this is a ctor decl with a typeParameterList and not a (return) type with a typeArgumentList until you get to the |
- Allow TYPE as name in most typeParameterLists (not for extern ctors)
Ooh, that is devious. -N On Wed, Oct 19, 2016 at 12:20 PM, Chris Dodd notifications@github.com
|
Actually we don't allow type parameters on constructors; if you need type parameters on a constructor, they have to be on the entire object.
|
Well, the implementation certainly allows it -- the rule for On Wed, Oct 19, 2016 at 1:14 PM, mbudiu-vmw notifications@github.com
|
As does the spec (although presumably this was generated from the Bison grammar)...
|
The proposed fix causes one test failure -- p4_16_errors/generic_e/p4, which is just:
The comment is correct in that there are two Ds in two different scopes, and the inner one shadows the outer one, but I'm not certain that it should be an error. It was previously giving a syntax error, which is definitely wrong (this is syntactically correct), but should it be a semantic error to have shadowing here? If so, we need a specific semantic check. |
If type parameter declarations are binders, I might emit a warning but -N On Wed, Oct 19, 2016 at 4:17 PM, Chris Dodd notifications@github.com
|
Since extern declarations are part of the architecture, and they contain nothing but method declarations, I think that shadowing a type parameter is a really a bug in the library's design, which will confuse users. It's bad style, and it should be discouraged strongly. |
Another view is that for all binders we morally work up to alpha extern X void f(in D d); or equivalently extern X void f(in E d); or equivalently extern X void f(in B d); and so on, all of which are totally sensible. Hence, my preference for the On Wed, Oct 19, 2016 at 4:24 PM, mbudiu-vmw notifications@github.com
|
- Allow TYPE as name in typeParameterLists - Remove optional type params from ctor decl
@mbudiu-vmw when you have a moment could you clarify "Actually we don't allow type parameters on constructors; if you need type parameters on a constructor, they have to be on the entire object." We should fix the spec if this is what's wanted... |
At least a partial fix has made it to the spec: the grammar does not allow type parameters on a constructor. I don't know if the text emphasizes it. |
Aha. I see it now. Thanks. |
This program compiles successfully using
p4test
while this program fails,
with an error:
Typically type parameters are binders so one wouldn't expect a prior declaration to affect whether the declaration of
f
is syntactically valid or not.The text was updated successfully, but these errors were encountered: