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
- Install VBA Pro extension version
1.7.4 (notisdataanalytics.vba-lsp) in VS Code on Windows.
- Open a workspace containing a
.bas VBA module.
- Add code below to module.
- Open module or allow VBA Pro language server to index workspace.
- 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)
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
Windowsfrom built-inMaccompiler constant.#Const Windows = (Mac = 0)is valid in Excel VBA/VBE. VBA Pro 1.7.4 evaluatesWindowsasnull, then crashes when processing a later#If Windows Then.This produces:
After failure, many misleading
Cannot add name ...messages appear while language server builds project symbol table.To Reproduce
1.7.4(notisdataanalytics.vba-lsp) in VS Code on Windows..basVBA module.Actual result
Language server reports:
It may also emit multiple follow-on errors like:
Code (if relevant)
Real project uses this valid pattern from VBA-FileTools:
Expected behavior
VBA Pro should evaluate
Windowsas Boolean and parse#If Windows Thenblocks 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
notisdataanalytics.vba-lsp) version1.7.4