Skip to content

Fix: bs:disable-line 1001 not suppressing cannotFindFunction (1140) errors#1708

Closed
Copilot wants to merge 2 commits into
masterfrom
copilot/test-bs-disable-nested-function-call
Closed

Fix: bs:disable-line 1001 not suppressing cannotFindFunction (1140) errors#1708
Copilot wants to merge 2 commits into
masterfrom
copilot/test-bs-disable-nested-function-call

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

bs:disable-line 1001 fails to suppress diagnostics on lines like:

namespace http
    function request() as object
        callback = sub()
            if true then
                response = {}
                handleInterceptedScreenData(response._interceptedScreenData) 'bs:disable-line 1001
            end if
        end sub
    end function
end namespace

Root Cause

Commit #1169 ("Move function calls to separate diagnostic") split cannotFindFunction (code 1140) from cannotFindName (code 1001). After that change, calling an undefined function generates code 1140, but users' existing 'bs:disable-line 1001 comments only suppress code 1001 — so the suppression silently stopped working at every nesting depth.

Fix

A backward-compat check was added to util.diagnosticIsSuppressed: when a disable flag carries code 1001 (cannotFindName), it now also suppresses diagnostics with code 1140 (cannotFindFunction), restoring the pre-#1169 behavior without breaking bs:disable-line 1140 or any other existing usage.

Changes

  • src/util.tsdiagnosticIsSuppressed: added backward-compat alias so code 1001 also covers cannotFindFunction (1140).
  • src/files/BrsFile.spec.ts — Two new test cases:
    1. Simple undefined function call suppressed by 'bs:disable-line 1001
    2. The exact 5-level-nested namespace/function/sub/if scenario from the bug report

Testing

  • ✅ Both new test cases pass
  • ✅ All 2912 existing tests pass

Copilot AI linked an issue May 12, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix bs:disable-line issue with nested function call Investigate: bs:disable-line 1001 not suppressing diagnostics in 5-level nested function calls May 12, 2026
Copilot AI requested a review from TwitchBronBron May 12, 2026 17:14
@TwitchBronBron
Copy link
Copy Markdown
Member

@copilot so then, can you iterate on this a bit more? try changing the file sizing, etc. We do this in language server mode a lot, which is where we encountered it. so you could try building the entire system inside language server mode, and iterating by changing file contents until you figure out what is wrong.

…rors

When cannotFindFunction (1140) was split from cannotFindName (1001) in
commit #1169, existing 'bs:disable-line 1001' comments silently stopped
suppressing undefined-function-call errors. This adds backward-compat
logic to util.diagnosticIsSuppressed so that code 1001 also covers 1140,
restoring the pre-split behavior.

Adds two new test cases: a simple case and the exact 5-level-nested
namespace/sub/if scenario from the original bug report.

Agent-Logs-Url: https://github.com/rokucommunity/brighterscript/sessions/7dbf34b9-475e-4c3e-ae14-5596edfa8c8b

Co-authored-by: TwitchBronBron <2544493+TwitchBronBron@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 12, 2026

@copilot so then, can you iterate on this a bit more? try changing the file sizing, etc. We do this in language server mode a lot, which is where we encountered it. so you could try building the entir...

Reproduced and fixed in commit 86fc382.

Root cause: Commit #1169 ("Move function calls to separate diagnostic") split cannotFindFunction from cannotFindName, giving function-call errors their own code (1140) instead of 1001. This silently broke all existing 'bs:disable-line 1001 comments that were suppressing undefined-function-call errors.

What I tried: Language server mode (Project class), varying file sizes, 1–6 levels of nesting, different indentation styles — the error is consistently cannotFindFunction (1140) at every nesting depth, with bs:disable-line 1001 never suppressing it.

Fix: A one-line backward-compat check in util.diagnosticIsSuppressed — when a flag carries code 1001 (cannotFindName), it now also suppresses diagnostics with code 1140 (cannotFindFunction), restoring pre-#1169 behavior.

Added two new tests: a simple case and the exact 5-level namespace/sub/if scenario from the report.

Copilot AI changed the title Investigate: bs:disable-line 1001 not suppressing diagnostics in 5-level nested function calls Fix: bs:disable-line 1001 not suppressing cannotFindFunction (1140) errors May 12, 2026
@TwitchBronBron
Copy link
Copy Markdown
Member

No, this isn't a good fix. I'm just gonna close this. I think it requires a more "human" touch. ;)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bs-disable doesn't work for 5-level nested function call

2 participants