Report diagnostic on correct node#53538
Conversation
| // (12,27): error CS0029: Cannot implicitly convert type 'System.Index' to 'int' | ||
| // Console.WriteLine(s[new Index(1, false), ^1]); | ||
| Diagnostic(ErrorCode.ERR_NoImplicitConv, "s[new Index(1, false), ^1]").WithArguments("System.Index", "int").WithLocation(12, 27)); | ||
| Diagnostic(ErrorCode.ERR_NoImplicitConv, "^1").WithArguments("System.Index", "int").WithLocation(12, 27)); |
There was a problem hiding this comment.
Do the locations need to be updated too?
There was a problem hiding this comment.
Yep I forgot those. Will update them shortly.
davidwengier
left a comment
There was a problem hiding this comment.
Thanks @Youssef1313 😀
IDE test change LGTM
| // (11,17): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray' | ||
| // var x = arr[0..2]; | ||
| Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "arr[0..2]").WithArguments("System.Runtime.CompilerServices.RuntimeHelpers", "GetSubArray").WithLocation(11, 17)); | ||
| Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "0..2").WithArguments("System.Runtime.CompilerServices.RuntimeHelpers", "GetSubArray").WithLocation(11, 21)); |
There was a problem hiding this comment.
-
Will add a test for pointer indexing.
-
Array creation is covered in `CS0266ERR_NoImplicitConvCast13:
roslyn/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs
Lines 9235 to 9244 in 67c6bed
- If you mean
int[o] arr;, then this will produceerror CS0270: Array size cannot be specified in a variable declaration (try initializing with a 'new' expression).
There was a problem hiding this comment.
If you mean int[o] arr;, then this will produce error CS0270: Array size cannot be specified in a variable declaration (try initializing with a 'new' expression).
Do we have an existing test demonstrating this with type mismatch in the illegal sizes?
There was a problem hiding this comment.
@AlekseyTs If you mean something like:
public void M(object o) {
int[o] x;
}
Then I think there is no test for it. I'll add it once you confirm this is the case you're requesting.
There was a problem hiding this comment.
If you mean something like ...
Yes, something like this. We want a test that hits your changes in BindArrayDimension for a variable declaration
|
@Youssef1313 It looks like there are legitimate test failures. |
|
Done with review pass (commit 4) In reply to: 845142404 |
|
Done with review pass (commit 6) In reply to: 845185257 |
|
@dotnet/roslyn-compiler For the second review. |
|
Thanks for the contribution @Youssef1313! |
…ures/interpolated-string * upstream/main: (92 commits) Keep casts when necessary to prefer a constant pattern over a type pattern Remove SyntaxKind.DataKeyword (#53614) Display 'readonly' for record structs (#53634) Update Building, Debugging, and Testing on Windows.md (#53543) Update dependencies from https://github.com/dotnet/arcade build 20210521.3 (#53617) Introduce resx for BuildValidator and MS.CA.Rebuild to allow localization (#53447) Report obsoletion diagnostics for slice and indexer (#53463) Update BasicGenerateConstructorDialog.cs Add searchbox in generate overrides dialog Allow `with` on anonymous types (#53248) Report diagnostic on correct node (#53538) Fix NotNullIfNotNull delegate conversion (#53409) Verify quick info session in InvokeQuickInfo Remove unnecessary retry Ensure no navbar IO on the UI thread Enable nullable reference types Fix timeout behavior in GetQuickInfo Add a semantic model based GetQuickInfoAsync entry point into QuickInfoServiceWithProviders Move semantic model based quick info API up to CommonQuickInfoProvider type Fix dnceng build by forcing the use of xcopy msbuild ...
Fixes #53536
Fixes #50493