-
Notifications
You must be signed in to change notification settings - Fork 326
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: Full constructor syntax for type definitions; Field syntax; Complex operator sections; Template functions; Text improvements; Operator methods; eliminate Unsupported; better ArgumentDefinitions #3716
Conversation
(Not ready for integration: I'm planning further changes to TypeDef tomorrow.) |
data = ['data', self.to_vector.take (First max_data)]) | ||
data = ['data', self.to_vector.take (First max_data)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, the fact that we did not notice this is slightly concerning
} | ||
|
||
private Option<IdentifiedLocation> getIdentifiedLocation(Token ast) { | ||
return Option.apply(ast).map(ast_ -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a lot of functional style rewrites in this file! @kazcw, looks like you can (unlike me) write functionally (even) in Java.
Tree treeBody = null; | ||
Tree.OprApp head = app; | ||
while (head != null) { | ||
// FIXME: Handle parameterized types here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have an Enso source example that needs handling?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test case, with @Ignore
for now. Before this PR, the test case fails due to incorrect IR (the previous code here flattened all types and their parameters into one list); after this PR, the unhandled case throws an exception from the line under this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see there is a failure in javac compilation:
INFO ide_ci::program::command: sbtℹ️ [warn] java.lang.AssertionError
INFO ide_ci::program::command: sbtℹ️ [warn] at com.sun.tools.javac.util.Assert.error(Assert.java:155)
INFO ide_ci::program::command: sbtℹ️ [warn] at com.sun.tools.javac.util.Assert.check(Assert.java:46)
INFO ide_ci::program::command: sbtℹ️ [warn] at com.sun.tools.javac.code.Scope$ScopeImpl.leave(Scope.java:386)
INFO ide_ci::program::command: sbtℹ️ [warn] at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1474)
INFO ide_ci::program::command: sbtℹ️ [warn] at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1082)
INFO ide_ci::program::command: sbtℹ️ [warn] at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:696)
INFO ide_ci::program::command: sbtℹ️ [warn] at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:770)
INFO ide_ci::program::command: sbtℹ️ [warn] at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1262)
INFO ide_ci::program::command: sbtℹ️ [warn] at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:912)
INFO ide_ci::program::command: sbtℹ️ [warn] at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:696)
INFO ide_ci::program::command: sbtℹ️ [warn] at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:770)
INFO ide_ci::program::command: sbtℹ️ [warn] at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:5637)
I've had similar error yesterday and had to rewrite my code to be less fancy. The hardest task is to find the code that is causing the assert, however.
} else if (ast.getOpen2() != null) { | ||
begin = ast.getOpen2().getStartCode(); | ||
} else if (ast.getSuspension() != null) { | ||
begin = ast.getSuspension().getStartCode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open, open2, suspension!? That's complicated. Simple ArgumentDefinition.getOpen()
with proper behavior would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getOpen
returns the outer parenthesis, if present. This logic is finding the textual begin and end of the ArgumentDefinition
; which token begins the object depends on what syntax occurred within the argument definition. A pattern is always present, but there are optional parts that can extend to either side of it: A type annotation, a default value, and a ~
suspension operator, along with up to two pairs of parentheses (one around the type annotation and one around the default value). As noted in the comment earlier in the function, I think the proper solution is to refactor the IR so that its DefinitionArgument
is not a node, and doesn't need a code span; however, I looked in to doing that, and it would require changes all across the compiler. I don't think it's worth it; this works.
Wow, I thought that was a transient glitch. We actually have to deal with a flaky compiler? I don't even know where to start debugging this, since it builds fine on my machine. |
Fixed in 5869412 - I could reproduce the problem by doing:
now it seems to be fixed. Btw. please take a look at my conflict resolution: e1c4b0a - it may not be correct. |
e1c4b0a
to
5869412
Compare
@@ -438,7 +438,6 @@ impl<'s> Resolver<'s> { | |||
self.replace_current_with_parent_macro(parent_macro); | |||
Step::MacroStackPop(token.into()) | |||
} else if let Some(segments) = root_macro_map.get(repr) { | |||
// } else if let Some(segments) = root_macro_map.get(repr) && token.variant.can_start_macro() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure which line to keep...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your choice was correct, thanks for handling that merge. And thanks for fixing my too-fancy-for-the-compiler attempt at downcasting, I think instanceof
is probably the more idiomatic implementation there anyway.
Another lint: https://github.com/enso-org/enso/actions/runs/3182851703/jobs/5189331859 - did I merge improperly?
|
No, the code here is fine. There was a |
Pull Request Description
I believe all parse failures remaining after these changes are because the new parser is intentionally stricter about some things. I'll be reviewing those failures and opening a bug to change the library/tests code.
Implements:
codeRepr
without leading whitespace<=
operator is no longer treated as a modifierBreaking API changes
TypeDef is more specifically typed:
name
has been restricted fromTree
toIdent
Tree
toArgumentDefinition
ArgumentDefinition
now parses the default-value, ascribed-type, and execution-suspension-operator into fields, so that information can no longer be obtained by decomposing thepattern
field.Checklist
Please include the following checklist in your PR:
Scala,
Java,
and
Rust
style guides.
./run ide build
and./run ide watch
.[ci no changelog needed]