-
Notifications
You must be signed in to change notification settings - Fork 80
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
parser rejects valid: 'ubyte a[1]; ' #60
Comments
I think that error message explains itself fairly well. |
I know, but it's still a bug: D code in production still relies on it (in rdmd etc); it should be a warning, not an error, and at least parse the rest of the file even if it skips this declaration. |
The fact that DMD still supports C syntax at all is a bug because it doesn't do so properly. http://d.puremagic.com/issues/show_bug.cgi?id=953 |
I agree it is a misfeature, but both ldc and dmd accept it, so dscanner should match their behavior. I see nothing wrong with just reporting a warning instead of errro (besides additional coding time of course :-) ). |
I don't think emitting a warning is enough, since you'd end up with a wrong AST tree. You need to actually implement parsing for this, but why bother doing all that work for a deprecated feature? The only reason I could think of implementing this is if you wanted to auto-translate deprecated syntax into the proper syntax. But in that case such a conversion app can override I think we should close this. @Hackerpilot? |
I agree with @timotheecour - in order to do AST->source conversion properly, dscanner should parse whatever dmd does (bugs in dmd aside). We can always warn about it, let the user decide whether they want to treat it as any error. Far as I can tell, dmd only allows array decls (it doesn't do the semantic properly as noted, but it shouldn't matter):
Where only arrays are allowed (syntactically). I have a possible patch for this here: https://github.com/callumenator/Dscanner/tree/c-style Basically, it just adds a typesuffix array to the declarator, and parses typesuffixes after the identifier when it sees an opening |
Note dmd also allows them for parameters:
This appears in phobos (regex at least) |
Support for variables with c-style array syntax is present in libdparse now. I'm leaving this open since it seems dscanner does not dump the correct AST for c-style array function parameters. |
this is accepted now in dparse. |
=> error: C-style variable declarations are not supported.
The text was updated successfully, but these errors were encountered: