Skip to content

[Bug] VBA Pro language server fails to parse valid VBA conditional-compilation code that derives Windows from built-in Mac compiler constant #105

Description

@kk738

Describe the bug

Produced by GPT-5.6 Terra, adapted by me
VBA Pro language server fails to parse valid VBA conditional-compilation code that derives Windows from built-in Mac compiler constant.

#Const Windows = (Mac = 0) is valid in Excel VBA/VBE. VBA Pro 1.7.4 evaluates Windows as null, then crashes when processing a later #If Windows Then.

This produces:

Failed to parse .../LibFileTools.bas
Error: Expected boolean result from WINDOWS => null.

After failure, many misleading Cannot add name ... messages appear while language server builds project symbol table.


To Reproduce

  1. Install VBA Pro extension version 1.7.4 (notisdataanalytics.vba-lsp) in VS Code on Windows.
  2. Open a workspace containing a .bas VBA module.
  3. Add code below to module.
  4. Open module or allow VBA Pro language server to index workspace.
  5. View VBA Pro Output channel.

Actual result

Language server reports:

Failed to parse file:///.../Example.bas
Error: Expected boolean result from WINDOWS => null.

It may also emit multiple follow-on errors like:

Cannot add name Collection
Cannot add name SomeType
Cannot add name SomeClass

Code (if relevant)

Option Explicit

#Const Windows = (Mac = 0)

#If Windows Then
    Public Const PlatformName As String = "Windows"
#End If

Real project uses this valid pattern from VBA-FileTools:

#Const Windows = (Mac = 0)

#If Mac Then
    ' Mac-specific declarations
#Else
    ' Windows-specific declarations
#End If

#If Windows Then
    ' Windows-specific types and code
#End If

Expected behavior

VBA Pro should evaluate Windows as Boolean and parse #If Windows Then blocks normally.

At minimum, language server should not crash or produce unrelated Cannot add name ... errors after encountering valid conditional-compilation expressions.

VBA/VBE accepts and compiles same source correctly.


Screenshots

Not applicable. Output log captures failure.


Additional context

  • OS: Windows
  • Extension: VBA Pro (notisdataanalytics.vba-lsp) version 1.7.4
  • Failure occurs while parsing LibFileTools.bas.
  • Relevant stack trace:
Error: Expected boolean result from WINDOWS => null.
    at get conditionResult (...\notisdataanalytics.vba-lsp-1.7.4\dist\server\out\server.js:55:285)
    at new Np (...\server.js:54:15329)
    at r.enterCompilerIfBlock (...\server.js:56:3211)
    at Yi.parseDocument (...\server.js:57:3845)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions