Skip to content

Fix #7931: Resolve opened namespaces for attributes in recursive scopes#19502

Draft
Copilot wants to merge 19 commits intomainfrom
copilot/fix-9141961-29048891-9983b77b-6647-424c-befc-6bcc6711d784
Draft

Fix #7931: Resolve opened namespaces for attributes in recursive scopes#19502
Copilot wants to merge 19 commits intomainfrom
copilot/fix-9141961-29048891-9983b77b-6647-424c-befc-6bcc6711d784

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 26, 2026

Description

Fixes nested module attributes not being resolved in namespace rec / module rec scopes. Previously, using [<Extension>] on a module inside namespace rec would fail with FS0039: The type 'Extension' is not defined, even when open System.Runtime.CompilerServices was in scope.

Root Cause

In recursive scopes, open declarations are processed in Phase1AB — after Phase1A builds module/type entities. But module attributes are checked during Phase1A using envInitial, which doesn't yet include the opened namespaces. In non-recursive scopes, opens are processed sequentially before module attributes are checked, so this issue doesn't occur.

Changes Made

  • src/Compiler/Checking/CheckDeclarations.fs: Added preProcessOpensForPhase1A helper that silently resolves open declarations before Phase1A attribute checking. Uses suppressErrorReporting and TemporarilySuspendReportingTypecheckResultsToSink to avoid duplicate diagnostics (since opens are re-processed properly in Phase1AB). Applied at two levels:
    1. Top-level opens in TcMutRecDefns_Phase1 (fixes namespace rec case)
    2. Inner opens in TcTyconDefnCore_Phase1A_BuildInitialModule (fixes nested module case)
  • Regression tests: Added 8 test cases in AttributeResolutionInRecursiveScopes.fs covering the issue scenarios (Extension attribute on modules/types in namespace rec, nested modules, multiple opens, module rec, and non-recursive baseline).
  • Release notes: Added entry to docs/release-notes/.FSharp.Compiler.Service/11.0.100.md.

Testing

  • All 8 new regression tests pass
  • All 158 existing custom attribute tests pass
  • 636/638 broader conformance tests pass (2 failures are pre-existing and unrelated)

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

@T-Gro
Copy link
Copy Markdown
Member

T-Gro commented Mar 27, 2026

@copilot : Try again

@T-Gro
Copy link
Copy Markdown
Member

T-Gro commented Mar 27, 2026

@copilot : Try again.

@abonie
Copy link
Copy Markdown
Member

abonie commented Mar 31, 2026

@copilot Try again

Copilot AI and others added 14 commits March 31, 2026 15:13
… element (#19464)

Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
#19341)

Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
* Add Regression PR Shepherd agentic workflow

Shepherds open AI-Issue-Regression-PR pull requests to completion:
- Fixes CI failures and addresses review feedback
- Detects when a test proves the bug still exists (removes label, tags maintainers)
- Runs 6x/day, only touches tests/ files

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add min-integrity: none

* Add min-integrity: none

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
…it, stricter labeling (#19499)

- Enable create-pull-request and push-to-pull-request-branch for regression test PRs
- Enable remove-labels for AI-thinks-issue-fixed and AI-thinks-windows-only
- Add Task 2: Regression Test Verification with adversarial dispute step
- Add Task 3: Systematic revisit of AI-thinks-windows-only claims
- Reorder tasks: Task 1 → Task 3 → Task 2 → FINAL (Task 3 feeds into Task 2)
- Strict windows-only rules with explicit FCS-testable feature list
- Fix memory section to match actual state.json schema
- Remove close-issue actions (closure happens via PR merge with Fixes link)
- Fix stale references, contradictory instructions, date cutoff to 2024
- Clarify anti-spam rules for multi-task commenting

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
…327.7 (#19512)

On relative base path root
Microsoft.DotNet.Arcade.Sdk From Version 10.0.0-beta.26168.1 -> To Version 10.0.0-beta.26177.7

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
* Update dependencies from https://github.com/dotnet/msbuild build 20260324.4
On relative base path root
Microsoft.Build , Microsoft.Build.Framework , Microsoft.Build.Tasks.Core , Microsoft.Build.Utilities.Core From Version 18.6.0-preview-26173-02 -> To Version 18.6.0-preview-26174-04

* Update dependencies from https://github.com/dotnet/msbuild build 20260325.1
On relative base path root
Microsoft.Build , Microsoft.Build.Framework , Microsoft.Build.Tasks.Core , Microsoft.Build.Utilities.Core From Version 18.6.0-preview-26173-02 -> To Version 18.6.0-preview-26175-01

* Update dependencies from https://github.com/dotnet/msbuild build 20260326.1
On relative base path root
Microsoft.Build , Microsoft.Build.Framework , Microsoft.Build.Tasks.Core , Microsoft.Build.Utilities.Core From Version 18.6.0-preview-26173-02 -> To Version 18.6.0-preview-26176-01

* Update dependencies from https://github.com/dotnet/msbuild build 20260327.2
On relative base path root
Microsoft.Build , Microsoft.Build.Framework , Microsoft.Build.Tasks.Core , Microsoft.Build.Utilities.Core From Version 18.6.0-preview-26173-02 -> To Version 18.6.0-preview-26177-02

---------

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
…f`1 (#19485)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
…#19480)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
* Add regression test for #13519: C# optional parameters from F#

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add ParamArray + optional params regression test for #13519

Addresses reviewer feedback: the original issue was specifically about
the intersection of omitted optional arguments and ParamArray arguments,
as identified by Don Syme. This adds a test covering that exact scenario.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
)

* Add regression test for #6648: DU of DUs with inline static members

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix unclosed triple-quoted string in Issue 6648 regression test

Add missing closing triple-quote and assertion pipeline to the
DU of DUs with inline static members test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
)

* Initial plan

* Fix repo-assist: add safe output discipline, iteration limits, and noop fallback

Root cause: Agent spent ~37 minutes creating ~25 test files across 5+ issues
without calling any safe output MCP tools, resulting in empty agent_output.json.

- Add "Safe Output Discipline" section with incremental output, noop fallback,
  3-attempt iteration limit per issue, and time awareness rules
- Task 1: call safe output tools immediately after each issue
- Task 2: limit build-and-test cycles to 3 per issue, create PRs immediately,
  do not create multiple test file variants

Agent-Logs-Url: https://github.com/dotnet/fsharp/sessions/cf589816-f234-44e2-9245-742907ee5d27

Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>

* Run gh aw upgrade and gh aw compile to regenerate lock files

Updates gh-aw from v0.64.2 to v0.64.4:
- Regenerate repo-assist.lock.yml with new frontmatter hash
- Regenerate regression-pr-shepherd.lock.yml
- Update actions-lock.json with new action SHAs
- Update agentic-workflows.agent.md version references

Agent-Logs-Url: https://github.com/dotnet/fsharp/sessions/0f6b9ce7-da31-403c-b633-6bb5f004484e

Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
Co-authored-by: Tomas Grosup <Tomas.Grosup@gmail.com>
Co-authored-by: Adam Boniecki <20281641+abonie@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
…0330.8 (#19525)

On relative base path root
Microsoft.Build , Microsoft.Build.Framework , Microsoft.Build.Tasks.Core , Microsoft.Build.Utilities.Core From Version 18.6.0-preview-26177-02 -> To Version 18.6.0-preview-26180-08

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
…otnet-optimization build 20260330.1 (#19523)

On relative base path root
optimization.linux-arm64.MIBC.Runtime , optimization.linux-x64.MIBC.Runtime , optimization.windows_nt-arm64.MIBC.Runtime , optimization.windows_nt-x64.MIBC.Runtime , optimization.windows_nt-x86.MIBC.Runtime From Version 1.0.0-prerelease.26153.1 -> To Version 1.0.0-prerelease.26180.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
T-Gro and others added 4 commits March 31, 2026 15:13
* Add aw-auto-update workflow for daily gh aw upgrade/compile

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Update agentic workflows via gh aw upgrade (v0.64.2 → v0.64.4)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
Verifies that land, lor, lxor, lsl, lsr, and asr can be used as valid
identifiers after the ML compatibility removal in PR #19143.

Fixes #6715

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
Pre-process open declarations before Phase1A attribute checking in
recursive scopes (namespace rec / module rec). Previously, opens were
only processed in Phase1AB after module entities were built, but module
attributes needed access to opened namespaces during Phase1A.

The fix adds preProcessOpensForPhase1A which silently resolves opens
before Phase1A, making opened namespaces available for attribute
resolution on modules and types in recursive scopes.

Agent-Logs-Url: https://github.com/dotnet/fsharp/sessions/20a6e4bb-a5f1-45cc-b80d-ee1110cd8812

Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/fsharp/sessions/20a6e4bb-a5f1-45cc-b80d-ee1110cd8812

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

Copilot AI commented Mar 31, 2026

@copilot Try again

Implemented the fix in commit d0e2dac (with release notes in c8d283c).

Root cause: In recursive scopes (namespace rec/module rec), open declarations were only processed in Phase1AB — after Phase1A builds module entities. But module attributes need opened namespaces during Phase1A.

Fix: Added preProcessOpensForPhase1A that silently resolves opens before Phase1A attribute checking, applied at both the top level and nested module level. All 158 custom attribute tests pass, plus 8 new regression tests for issue #7931.

Copilot AI changed the title [WIP] Copilot Request Fix #7931: Resolve opened namespaces for attributes in recursive scopes Mar 31, 2026
Copilot AI requested a review from abonie March 31, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

3 participants