-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-CompilersBugConcept-Diagnostic ClarityThe issues deals with the ease of understanding of errors and warnings.The issues deals with the ease of understanding of errors and warnings.Feature - RecordsRecordsRecords
Description
I'm not sure how to improve this, but I'm concerned it's going to cause a lot of confusion with users.
We should also test the scenario with record nested in another type.
[Fact]
public void Test()
{
var src = @"
record R(int P = 42)
{
}
";
var comp = CreateCompilation(new[] { src, IsExternalInitTypeDefinition }, parseOptions: TestOptions.Regular8);
comp.VerifyDiagnostics(
// error CS8805: Program using top-level statements must be an executable.
Diagnostic(ErrorCode.ERR_SimpleProgramNotAnExecutable).WithLocation(1, 1),
// (2,1): error CS8652: The feature 'top-level statements' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version.
// record R(int P = 42)
Diagnostic(ErrorCode.ERR_FeatureInPreview, @"record R(int P = 42)
{
}").WithArguments("top-level statements").WithLocation(2, 1),
// (2,1): error CS0246: The type or namespace name 'record' could not be found (are you missing a using directive or an assembly reference?)
// record R(int P = 42)
Diagnostic(ErrorCode.ERR_SingleTypeNameNotFound, "record").WithArguments("record").WithLocation(2, 1),
// (2,8): error CS0161: 'R(int)': not all code paths return a value
// record R(int P = 42)
Diagnostic(ErrorCode.ERR_ReturnExpected, "R").WithArguments("R(int)").WithLocation(2, 8),
// (2,8): warning CS8321: The local function 'R' is declared but never used
// record R(int P = 42)
Diagnostic(ErrorCode.WRN_UnreferencedLocalFunction, "R").WithArguments("R").WithLocation(2, 8)
);
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-CompilersBugConcept-Diagnostic ClarityThe issues deals with the ease of understanding of errors and warnings.The issues deals with the ease of understanding of errors and warnings.Feature - RecordsRecordsRecords