Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record syntax in LangVer=8 should not complain about top-level statement #45900

Closed
jcouv opened this issue Jul 10, 2020 · 3 comments
Closed

Record syntax in LangVer=8 should not complain about top-level statement #45900

jcouv opened this issue Jul 10, 2020 · 3 comments
Labels
Area-Compilers Bug Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings. New Language Feature - Records Records

Comments

@jcouv
Copy link
Member

jcouv commented Jul 10, 2020

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)
                );
        }
@jcouv jcouv added Area-Compilers Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings. New Language Feature - Records Records labels Jul 10, 2020
@jaredpar jaredpar added the Bug label Jul 27, 2020
@jaredpar jaredpar added this to the 16.8 milestone Jul 27, 2020
@jaredpar jaredpar modified the milestones: 16.8, Compiler.Next Aug 11, 2020
@jcouv jcouv modified the milestones: Compiler.Next, 16.8 Sep 2, 2020
@jcouv
Copy link
Member Author

jcouv commented Sep 2, 2020

FYI @CyrusNajmabadi

From our discussion, it would be good to at least provide a better/additional diagnostic, but ideally we would reparse as a record type. This could be staged between 16.8 and 16.9.

@jaredpar jaredpar modified the milestones: 16.8, 16.9 Oct 12, 2020
@jinujoseph jinujoseph modified the milestones: 16.9, 17.0 Jun 1, 2021
@jaredpar jaredpar modified the milestones: 17.0, 17.1 Sep 27, 2021
@jaredpar jaredpar modified the milestones: 17.1, 17.2 Jan 11, 2022
@jaredpar
Copy link
Member

@jcouv do you think we can do this in 17.2? If not think we should consider closing it out due to unlikelyness of it being completed.

@jcouv
Copy link
Member Author

jcouv commented Jan 11, 2022

I think it's unlikely we'll be able to get to this in 17.2. I don't think it's as big a problem as I initially thought because of how language versions work with updating the SDK. I'll go ahead and close.

@jcouv jcouv closed this as completed Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Bug Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings. New Language Feature - Records Records
Projects
None yet
Development

No branches or pull requests

3 participants