SSlinky / VBA-LanguageServer

VBA Language Server
GNU General Public License v3.0
16 stars 4 forks source link

[Bug] Parsing broken after functions with arrays as parameters #17

Open sancarn opened 3 months ago

sancarn commented 3 months ago

Describe the bug Initially I noticed this when the Option Explicit error wasn't applicable for stdCallback and stdLambda.

image

Now I realise though that the outline doesn't work for these either. So I assume parsing is just broken.

Both these modules have the following declare:

Private Function stdCallByName(ByRef obj As Object, ByVal funcName As String, ByVal callerType As VbCallType, ByRef args() As Variant) As Variant
  ...
End Function

after which it seems parsing breaks

image

To Reproduce

Minimally you can just load stdCallback or stdLambda into vscode.

sancarn commented 3 months ago

More specifically it seems to break when ByRef AND arrayQualifier () is explicitely declared...

Correct:

image

vs half-broken but recovers

image

vs fully broken

image

From the antlr grammar I can't see any reason why this would be failing though...

positionalParam: (parameterMechanism wsc)? paramDcl;
parameterMechanism
    : BYVAL
    | BYREF
    ;
paramDcl
    : untypedNameParamDcl
    | typedNameParamDcl
    ;
untypedNameParamDcl: ambiguousIdentifier parameterType?;
parameterType: arrayDesignator? wsc AS wsc (typeExpression | ANY);
arrayDesignator: '(' wsc? ')';

ambiguousIdentifier
    : IDENTIFIER
    | ambiguousKeyword
    ;
IDENTIFIER
    : [A-Z][A-Z0-9_]*
    ;
ambiguousKeyword
    : ACCESS
    | ALIAS
    | APPACTIVATE
    | APPEND
    ....
SSlinky commented 3 months ago

Thanks for reporting, but also for diving into it. I'll check it out when I get a chance (soon, hopefully).

SSlinky commented 1 week ago

This absolutely breaks syntax highlighting but I can't get it to break the parsing. Will attack this from a textmate grammar perspective.