Fix list patterns on pointer types causing internal compiler error#81059
Merged
CyrusNajmabadi merged 9 commits intomainfrom Nov 12, 2025
Merged
Fix list patterns on pointer types causing internal compiler error#81059CyrusNajmabadi merged 9 commits intomainfrom
CyrusNajmabadi merged 9 commits intomainfrom
Conversation
- 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
| public void PointerType_ListPattern() | ||
| { | ||
| var source = """ | ||
| unsafe class C |
Contributor
There was a problem hiding this comment.
@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.
Contributor
Author
… 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]>
333fred
reviewed
Nov 5, 2025
333fred
previously approved these changes
Nov 6, 2025
Member
333fred
left a comment
There was a problem hiding this comment.
Thanks for looking into more generic error handling, even if it didn't pan out.
jjonescz
reviewed
Nov 7, 2025
src/Compilers/CSharp/Test/Emit3/Semantics/PatternMatchingTests_ListPatterns.cs
Outdated
Show resolved
Hide resolved
AlekseyTs
reviewed
Nov 7, 2025
Contributor
|
Done with review pass (commit 4) #Closed |
AlekseyTs
reviewed
Nov 7, 2025
src/Compilers/CSharp/Test/Emit3/Semantics/PatternMatchingTests_ListPatterns.cs
Show resolved
Hide resolved
AlekseyTs
reviewed
Nov 7, 2025
src/Compilers/CSharp/Test/Emit3/Semantics/PatternMatchingTests_ListPatterns.cs
Show resolved
Hide resolved
Contributor
|
Done with review pass (commit 8) |
333fred
approved these changes
Nov 7, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
BindListPatternmethodERR_PointerTypeInPatternMatchingerror before attempting to bind indexer accessFiles Changed:
src/Compilers/CSharp/Portable/Binder/Binder_Patterns.cs
src/Compilers/CSharp/Test/Emit3/Semantics/PatternMatchingTests_ListPatterns.cs
PointerType_ListPatterntest with indented raw string literalFunctionPointerType_ListPatterntest with indented raw string literalTechnical Details:
The fix prevents the Debug.Assert failure that occurred when
BindElementAccessCorereturnedBoundPointerElementAccessfor 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.