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

parser errors in editor for advanced function types #575

Open
sbijoshj opened this issue Mar 7, 2017 · 5 comments
Open

parser errors in editor for advanced function types #575

sbijoshj opened this issue Mar 7, 2017 · 5 comments

Comments

@sbijoshj
Copy link

sbijoshj commented Mar 7, 2017

This issue is for valid Haxe code that compiles but gets red lines in the editor. The advanced function types are ones that start with optional parameters, and functions that pass functions. Code examples:

var a:?Int->Void;  // '(', ID, or '{' expected, got '?'
var f:Int->(Int->Void)->Void;  // <type or anonymous> or '?' expected, got '('

Plugin version: Version: 0.10.1.1 for IDEA 2016.1 through 2016.3.2
IDEA version: IntelliJ IDEA 2016.3.3 - Build #IU-163.11103.6, built on January 16, 2017
(IDEA JRE: 1.8.0_112-release-408-b6 x86)
(IDEA JVM: OpenJDK Server VM by JetBrains s.r.o)
OS and OS version: Windows 7 Ultimate SP1
JDK version: 1.8.0_45-b15

@EricBishton
Copy link
Member

EricBishton commented Mar 15, 2017

So, fixing the first one was easy. Just had to allow a question mark in the first position.

The second requires a lot of code changes because the underlying rule is really incorrect. Once putting the correct rule in place, the associated code changes require reworking of the resolver, which has the potential to break a lot of things. So, I'll document the correct rule here and maybe revisit this if it turns out we can't use the new compiler's parser. (github.com/vshaxe/hxparser)

replace:

private functionTypeWrapper ::= functionTypeOrWrapper functionType*
private functionTypeOrWrapper ::= '?'? typeOrAnonymous | '(' functionTypeWrapper ')'
left functionType ::= '->' '?'? typeOrAnonymous

with this:

private typeWrapper ::= functionType | typeOrAnonymous

functionArgument ::=  (typeOrAnonymous | ('(' functionType ')'))
private functionOptionalArgument ::= '?'? functionArgument
functionType ::= functionOptionalArgument '->' (functionOptionalArgument '->')* functionArgument {pin=2 recoverWhile="functionTypeRecovery"}
functionTypeRecovery ::= !('}' | ';' | '>' | '=')

@as3boyan
Copy link
Contributor

as3boyan commented Mar 16, 2017

BTW, nested function types #294
I can't remember how this works, but maybe that could help

@EricBishton
Copy link
Member

@as3boyan Thanks for the reminder. I had forgotten about that.

I found the exact same issue again (incorrectly built nested function types), and spent a few days trying to fix them. I need to move on at the moment, but I'll definitely be coming back to the issue.

EricBishton added a commit that referenced this issue Mar 18, 2017
@EricBishton
Copy link
Member

Part 1 fixed with #578. bdda8f0

@sbijoshj
Copy link
Author

🎉 Nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants