Skip to content
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

fix #158 - handle identifier list containing an indexing expression #159

Merged
11 commits merged into from
Aug 1, 2017

Conversation

ghost
Copy link

@ghost ghost commented Jul 23, 2017

No description provided.

@ghost ghost changed the title fix #158 - handle identifier list containing an indexing expression [WIP] fix #158 - handle identifier list containing an indexing expression Jul 23, 2017
@dlang-bot dlang-bot added the WIP label Jul 23, 2017
@ghost
Copy link
Author

ghost commented Jul 23, 2017

The fix is wrong, T[0].T[1].T is well parsed but only the last indexer is stored. The problem is that the indexer cannot be parsed in parseIdentifierOrTemplateInstance because it is used everywhere and would have consequences on the others constructs like the expressions.

In background the problem is that some kind of simplifications make the good fix harder than it looks.
https://dlang.org/spec/grammar.html#IdentifierList is not right in dparse.

@ghost
Copy link
Author

ghost commented Jul 23, 2017

I've made a nicer fix. As expected i had to create a new AST node type, so that each indexer of the chain is stored. As expected too all the tools break: D-Scanner, D-Symbol. The user tools that used Type2 will also break.

There's no other way to do that. I repeat myself but even if the bug was trivial, libdparse simplifies the AST so that things can be re-used (IdentifierOrTemplateChain here). One use case was forgotten and with the fix the IdentifierOrTemplateChain would not be reusable anymore.

Finally, if this get accepted i think that we should schedule this week, two hours during which the other tools could be fixed (because it requires each a time a review, a tag, etc).

@ghost ghost changed the title [WIP] fix #158 - handle identifier list containing an indexing expression fix #158 - handle identifier list containing an indexing expression Jul 24, 2017
@ghost ghost requested a review from Hackerpilot July 24, 2017 11:36
@ghost ghost removed the WIP label Jul 24, 2017
…ifierList can be named IdentifierList as in D specs

- extern decl content is also an IdentifierList
@ghost
Copy link
Author

ghost commented Jul 25, 2017

This good now. Summary of the changes:

@ghost ghost deleted a comment from codecov-io Jul 25, 2017
@ghost ghost deleted a comment from codecov-io Jul 25, 2017
@@ -3867,3 +3903,35 @@ protected:
"postblit"
];
}

version (unittest)
void testFormatNode(Node)(string sourceCode)
Copy link
Author

@ghost ghost Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use this new function to fix #135 and also problems in harbored-mod (which uses dparse formatter apparently...)

@codecov-io
Copy link

codecov-io commented Jul 25, 2017

Codecov Report

Merging #159 into master will decrease coverage by 0.29%.
The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #159     +/-   ##
=========================================
- Coverage   81.68%   81.39%   -0.3%     
=========================================
  Files           7        7             
  Lines        4542     4573     +31     
=========================================
+ Hits         3710     3722     +12     
- Misses        832      851     +19
Impacted Files Coverage Δ
src/dparse/ast.d 15.04% <0%> (-0.05%) ⬇️
src/dparse/parser.d 87.3% <86.95%> (-0.51%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6a19677...d45051b. Read the comment docs.

* ;)
* $(RULE identifierOrTemplateInstance)
* | $(RULE identifierOrTemplateInstance) $(LITERAL '.') $(RULE identifierList)
* | $(RULE identifierOrTemplateInstance) $(LITERAL '[') $(RULE assignExpression) $(LITERAL ']') $(LITERAL '.') $(RULE identifierList)
Copy link
Collaborator

@Hackerpilot Hackerpilot Jul 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The language spec and I disagree on the idea of "IdentifierList" being only a list of identifiers.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That and the idea of "lists" being separated by commas.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a chain, clearly.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not objecting to your change. It's consistent with the spec. I'm just upset with the spec.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There must be "chain" in the name. It's not a list.

Copy link
Author

@ghost ghost Jul 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only other use is with extern(c++).

stuff.accept(this);
format(&fmt, stuff);
assert(fmt.data.canFind(code), fmt.data);
writeln(fmt.data);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotta remove this writeln.

@ghost ghost merged commit abab226 into master Aug 1, 2017
ghost pushed a commit that referenced this pull request Aug 2, 2017
@ghost
Copy link
Author

ghost commented Aug 2, 2017

reverted. The changes are hard to handle.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants