Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix list patterns on pointer types causing internal compiler error#81059

Merged
CyrusNajmabadi merged 9 commits intomainfrom
copilot/fix-diagnostic-analyzer-error
Nov 12, 2025
Merged

Fix list patterns on pointer types causing internal compiler error#81059
CyrusNajmabadi merged 9 commits intomainfrom
copilot/fix-diagnostic-analyzer-error

Conversation

Copy link
Contributor

Copilot AI commented Nov 5, 2025

Fixes #70046

Fix list pattern on pointer type causing gold bar

Summary

Successfully fixed issue #70046 where using list patterns on pointer types caused an internal error ("gold bar") in Visual Studio.

Changes Complete:

  • Added early pointer/function pointer check in BindListPattern method
  • Reports ERR_PointerTypeInPatternMatching error before attempting to bind indexer access
  • Sets inputType to CreateErrorType() and recalculates narrowedType for consistency
  • Added comprehensive tests for both pointer and function pointer types with indented raw string literals
  • Fixed WorkItem references to point to correct issue Feature 'Diagnostic analyzer runner' fails with gold bar when encountering list pattern on pointer type #70046
  • All 215 list pattern tests pass
  • All 1343 pattern matching tests pass
  • Code review complete with no issues

Files Changed:

  1. src/Compilers/CSharp/Portable/Binder/Binder_Patterns.cs

    • Added pointer type check with proper error reporting
    • Moved narrowedType calculation after inputType modification
  2. src/Compilers/CSharp/Test/Emit3/Semantics/PatternMatchingTests_ListPatterns.cs

Technical Details:

The fix prevents the Debug.Assert failure that occurred when BindElementAccessCore returned BoundPointerElementAccess for pointer types. By checking for pointer/function pointer types early and reporting an appropriate error, the code now gracefully handles this case instead of crashing with an internal error.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 5, 2025 21:01
- Added pointer/function pointer check in BindListPattern to report ERR_PointerTypeInPatternMatching
- Added tests for both pointer and function pointer types with list patterns
- Prevents internal error when using list patterns on pointer types

Co-authored-by: CyrusNajmabadi <[email protected]>
- Remove redundant condition check by setting inputType to CreateErrorType()
- Make pointer type handling consistent with recursive pattern handling

Co-authored-by: CyrusNajmabadi <[email protected]>
Copilot AI changed the title [WIP] Fix diagnostic analyzer runner failure with pointer type Fix list patterns on pointer types causing internal compiler error Nov 5, 2025
Copilot AI requested a review from CyrusNajmabadi November 5, 2025 21:10
public void PointerType_ListPattern()
{
var source = """
unsafe class C
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot use raw string literals. Also, fixup all the workitems to point at 70046 instead. Also place the ); at the end of the prior line in all teh VerifyDiagnostics calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 737ce94. The raw string literals are now indented, WorkItem references updated to issue #70046, and VerifyDiagnostics closing parentheses moved to the end of the diagnostic lines.

… number

- Indent raw string literals for better formatting
- Change WorkItem from 70806 to 70046
- Move VerifyDiagnostics closing parenthesis to end of prior line
- Fix narrowedType calculation to occur after inputType is set to error type

Co-authored-by: CyrusNajmabadi <[email protected]>
Copilot AI requested a review from CyrusNajmabadi November 5, 2025 21:37
@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review November 5, 2025 23:09
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner November 5, 2025 23:09
333fred
333fred previously approved these changes Nov 6, 2025
Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into more generic error handling, even if it didn't pan out.

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Nov 7, 2025

Done with review pass (commit 4) #Closed

@AlekseyTs
Copy link
Contributor

Done with review pass (commit 8)

@AlekseyTs AlekseyTs requested a review from 333fred November 7, 2025 17:55
@AlekseyTs AlekseyTs dismissed 333fred’s stale review November 7, 2025 17:56

PR got changed

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (commit 9)

@CyrusNajmabadi CyrusNajmabadi merged commit 76a39c1 into main Nov 12, 2025
25 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the copilot/fix-diagnostic-analyzer-error branch November 12, 2025 06:53
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Nov 12, 2025
@davidwengier davidwengier modified the milestones: Next, 18.3 Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature 'Diagnostic analyzer runner' fails with gold bar when encountering list pattern on pointer type

6 participants