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

Disallow abstract member with access modifiers in sig file #17802

Merged
merged 17 commits into from
Oct 24, 2024

Conversation

ijklam
Copy link
Contributor

@ijklam ijklam commented Sep 26, 2024

Description

Disallow abstract member with access modifiers in signature files.

// in a .fsi file
type A =
    abstract internal B: int ->int
    abstract member C: int with internal get, private set

Before: All these will build successfully
After: Error FS0561: Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.

Checklist

  • Test cases added

@ijklam ijklam requested a review from a team as a code owner September 26, 2024 18:09
Copy link
Contributor

github-actions bot commented Sep 26, 2024

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/9.0.200.md

@KevinRansom
Copy link
Member

@Tangent-90 -
Hey, I was wondering why would an internal abstract member not be allowed on a public type? After all the assembly where it is defined, as well as friend assemblies can still implement it?

@ijklam
Copy link
Contributor Author

ijklam commented Sep 27, 2024

@Tangent-90 -
Hey, I was wondering why would an internal abstract member not be allowed on a public type? After all the assembly where it is defined, as well as friend assemblies can still implement it?

Hmm... I just simply find out that abstract internal in .fs file is not allowed, and in .fsi file will take no effect.

@ijklam
Copy link
Contributor Author

ijklam commented Sep 30, 2024

error when running Plain_Build_MacOS/Regular rebuild of FSharp.Compiler.Service.sln

Unhandled exception. System.BadImageFormatException: Bad IL format. The format of the file '/Users/runner/work/1/s/artifacts/bin/fsyacc/Debug/net9.0/osx-x64/fsyacc.dll' is invalid.
/var/folders/t5/14gs56bj7djcylkj26c908n40000gn/T/MSBuildTemprunner/tmpb55944d209f44f83b58b156af720d99b.exec.cmd: line 2: 4313 Abort trap: 6 "/Users/runner/hostedtoolcache/dotnet/dotnet" "/Users/runner/work/1/s/artifacts//bin/fsyacc/Debug/net9.0/osx-x64/fsyacc.dll" -o "/Users/runner/work/1/s/artifacts/obj/FSharp.Compiler.Service/Debug/net9.0/ilpars.fs" --module FSharp.Compiler.AbstractIL.AsciiParser --open FSharp.Compiler.AbstractIL.AsciiConstants --open FSharp.Compiler.AbstractIL.IL --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing --buffer-type-argument char AbstractIL/ilpars.fsy
/Users/runner/work/1/s/buildtools/buildtools.targets(54,5): error MSB3073: The command ""/Users/runner/hostedtoolcache/dotnet/dotnet" "/Users/runner/work/1/s/artifacts//bin/fsyacc/Debug/net9.0/osx-x64/fsyacc.dll" -o "/Users/runner/work/1/s/artifacts/obj/FSharp.Compiler.Service/Debug/net9.0/ilpars.fs" --module FSharp.Compiler.AbstractIL.AsciiParser --open FSharp.Compiler.AbstractIL.AsciiConstants --open FSharp.Compiler.AbstractIL.IL --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing --buffer-type-argument char AbstractIL/ilpars.fsy" exited with code 134. [/Users/runner/work/1/s/src/Compiler/FSharp.Compiler.Service.fsproj::TargetFramework=net9.0]

Copy link
Contributor

@edgarfgp
Copy link
Contributor

edgarfgp commented Oct 8, 2024

error when running Plain_Build_MacOS/Regular rebuild of FSharp.Compiler.Service.sln

Unhandled exception. System.BadImageFormatException: Bad IL format. The format of the file '/Users/runner/work/1/s/artifacts/bin/fsyacc/Debug/net9.0/osx-x64/fsyacc.dll' is invalid.
/var/folders/t5/14gs56bj7djcylkj26c908n40000gn/T/MSBuildTemprunner/tmpb55944d209f44f83b58b156af720d99b.exec.cmd: line 2: 4313 Abort trap: 6 "/Users/runner/hostedtoolcache/dotnet/dotnet" "/Users/runner/work/1/s/artifacts//bin/fsyacc/Debug/net9.0/osx-x64/fsyacc.dll" -o "/Users/runner/work/1/s/artifacts/obj/FSharp.Compiler.Service/Debug/net9.0/ilpars.fs" --module FSharp.Compiler.AbstractIL.AsciiParser --open FSharp.Compiler.AbstractIL.AsciiConstants --open FSharp.Compiler.AbstractIL.IL --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing --buffer-type-argument char AbstractIL/ilpars.fsy
/Users/runner/work/1/s/buildtools/buildtools.targets(54,5): error MSB3073: The command ""/Users/runner/hostedtoolcache/dotnet/dotnet" "/Users/runner/work/1/s/artifacts//bin/fsyacc/Debug/net9.0/osx-x64/fsyacc.dll" -o "/Users/runner/work/1/s/artifacts/obj/FSharp.Compiler.Service/Debug/net9.0/ilpars.fs" --module FSharp.Compiler.AbstractIL.AsciiParser --open FSharp.Compiler.AbstractIL.AsciiConstants --open FSharp.Compiler.AbstractIL.IL --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing --buffer-type-argument char AbstractIL/ilpars.fsy" exited with code 134. [/Users/runner/work/1/s/src/Compiler/FSharp.Compiler.Service.fsproj::TargetFramework=net9.0]

Seen this in the past. Had to close and reopen my PR multiple times until the CI is green.

Copy link
Contributor

github-actions bot commented Oct 8, 2024

src/Compiler/pars.fsy Outdated Show resolved Hide resolved
Copy link
Contributor

@edgarfgp edgarfgp 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 this. It improves by a mile the access modifiers error reporting in sig file.

@psfinaki
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

auto-merge was automatically disabled October 24, 2024 01:47

Head branch was pushed to by a user without write access

Copy link
Member

@psfinaki psfinaki left a comment

Choose a reason for hiding this comment

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

Alright then, let's get this in - thanks!

@psfinaki psfinaki merged commit 8b0900c into dotnet:main Oct 24, 2024
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants