Giter Site home page Giter Site logo

Comments (9)

Hackerpilot avatar Hackerpilot commented on May 19, 2024

I think that error message explains itself fairly well.

from d-scanner.

timotheecour avatar timotheecour commented on May 19, 2024

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.

from d-scanner.

Hackerpilot avatar Hackerpilot commented on May 19, 2024

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

from d-scanner.

timotheecour avatar timotheecour commented on May 19, 2024

I agree it is a misfeature, but both ldc and dmd accept it, so dscanner should match their behavior.
phobos uses that in many files, and many D production 3rd party libs do too.
If dscanner deviates, it just won't be usable with those.

I see nothing wrong with just reporting a warning instead of errro (besides additional coding time of course :-) ).

from d-scanner.

 avatar commented on May 19, 2024

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 parseDeclarator in its parser subclass and add this support. There's no need to add it to Dscanner itself.

I think we should close this. @Hackerpilot?

from d-scanner.

callumenator avatar callumenator commented on May 19, 2024

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):

Type ident TypeSuffix* (= init)? (, more)?

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 [. In my tests on phobos AST->source, this has no adverse affects and allows c-style usage that appears in some unittests. Thoughts?

from d-scanner.

callumenator avatar callumenator commented on May 19, 2024

Note dmd also allows them for parameters:

void a(int b[]){}

This appears in phobos (regex at least)

from d-scanner.

Hackerpilot avatar Hackerpilot commented on May 19, 2024

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.

from d-scanner.

 avatar commented on May 19, 2024

this is accepted now in dparse.

from d-scanner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.