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

Extern compilation no longer works #15269

Closed
nojaf opened this issue May 27, 2023 · 6 comments · Fixed by #15274
Closed

Extern compilation no longer works #15269

nojaf opened this issue May 27, 2023 · 6 comments · Fixed by #15274

Comments

@nojaf
Copy link
Contributor

nojaf commented May 27, 2023

Please provide a succinct description of the issue.

Repro steps

  • Create the following two files:

Lib.fsi

module Foo

[<System.Runtime.InteropServices.DllImport("")>]
val f: unit -> int

Lib.fs

module Foo

[<System.Runtime.InteropServices.DllImport("")>]
extern int f()
  • Compile with local compiler (latest main)

dotnet "C:\Users\nojaf\Projects\main-fsharp\artifacts\bin\fsc\Debug\net7.0\fsc.dll" --target:Library .\Lib.fsi .\Lib.fs

Expected behaviour

This would compile fine.

Actual behaviour

Microsoft (R) F# Compiler version 12.5.0.0 for F# 7.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
Process terminated. Assertion failed.
   at FSharp.Compiler.CheckExpressions.TcAndPublishValSpec@12133.Invoke(UnscopedTyparEnv tpenv, ValSpecResult valSpecResult) in C:\Users\nojaf\Projects\main-fsharp\src\Compiler\Checking\CheckExpressions.fs:line 12183
   at Microsoft.FSharp.Primitives.Basics.List.mapFold[TState,T,TResult](FSharpFunc`2 f, TState acc, FSharpList`1 xs) in C:\Users\nojaf\Projects\main-fsharp\src\FSharp.Core\local.fs:line 383
   at Microsoft.FSharp.Collections.ListModule.MapFold[T,TState,TResult](FSharpFunc`2 mapping, TState state, FSharpList`1 list) in C:\Users\nojaf\Projects\main-fsharp\src\FSharp.Core\list.fs:line 109
   at FSharp.Compiler.CheckDeclarations.TcSignatureElementNonMutRec@4514-1.Invoke(CancellationToken ct) in C:\Users\nojaf\Projects\main-fsharp\src\Compiler\Checking\CheckDeclarations.fs:line 4539
   at FSharp.Compiler.CheckDeclarations.TcSignatureElementNonMutRec@4514-15.Invoke(CancellationToken ct)
   at Internal.Utilities.Library.Cancellable.fold@876.Invoke(CancellationToken ct) in C:\Users\nojaf\Projects\main-fsharp\src\Compiler\Utilities\illib.fs:line 881
   at FSharp.Compiler.CheckDeclarations.TcModuleOrNamespaceSignatureElementsNonMutRec@4749-1.Invoke(CancellationToken ct)
   at FSharp.Compiler.CheckDeclarations.TcSignatureElementNonMutRec@4568-6.Invoke(CancellationToken ct)
   at FSharp.Compiler.CheckDeclarations.TcSignatureElementNonMutRec@4514-15.Invoke(CancellationToken ct)
   at Internal.Utilities.Library.Cancellable.fold@876.Invoke(CancellationToken ct) in C:\Users\nojaf\Projects\main-fsharp\src\Compiler\Utilities\illib.fs:line 881
   at FSharp.Compiler.CheckDeclarations.TcSignatureElementNonMutRec@4638-14.Invoke(CancellationToken ct)
   at FSharp.Compiler.CheckDeclarations.TcSignatureElementNonMutRec@4514-15.Invoke(CancellationToken ct)
   at Internal.Utilities.Library.Cancellable.fold@876.Invoke(CancellationToken ct) in C:\Users\nojaf\Projects\main-fsharp\src\Compiler\Utilities\illib.fs:line 881
   at FSharp.Compiler.CheckDeclarations.CheckOneSigFile@5536-2.Invoke(CancellationToken ct)
   at FSharp.Compiler.CheckDeclarations.CheckOneSigFile@5516-1.Invoke(CancellationToken ct) in C:\Users\nojaf\Projects\main-fsharp\src\Compiler\Checking\CheckDeclarations.fs:line 5536
   at FSharp.Compiler.ParseAndCheckInputs.CheckOneInput@1286-9.Invoke(CancellationToken ct)
   at FSharp.Compiler.ParseAndCheckInputs.CheckOneInput@1259-2.Invoke(CancellationToken ct) in C:\Users\nojaf\Projects\main-fsharp\src\Compiler\Driver\ParseAndCheckInputs.fs:line 1329
   at FSharp.Compiler.ParseAndCheckInputs.CheckOneInput@1258-17.Invoke(CancellationToken ct)
   at Internal.Utilities.Library.Cancellable.runWithoutCancellation[T](Cancellable`1 comp) in C:\Users\nojaf\Projects\main-fsharp\src\Compiler\Utilities\illib.fs:line 889
   at FSharp.Compiler.ParseAndCheckInputs.CheckOneInputEntry(CompilationThreadToken ctok, FSharpFunc`2 checkForErrors, TcConfig tcConfig, TcImports tcImports, TcGlobals tcGlobals, FSharpOption`1 prefixPathOpt, TcState tcState, ParsedInput input) in C:\Users\nojaf\Projects\main-fsharp\src\Compiler\Driver\ParseAndCheckInputs.fs:line 1384
   at FSharp.Compiler.ParseAndCheckInputs.CheckMultipleInputsSequential@1421.Invoke(TcState tcState, ParsedInput input)
   at Microsoft.FSharp.Primitives.Basics.List.mapFold[TState,T,TResult](FSharpFunc`2 f, TState acc, FSharpList`1 xs) in C:\Users\nojaf\Projects\main-fsharp\src\FSharp.Core\local.fs:line 390
   at Microsoft.FSharp.Collections.ListModule.MapFold[T,TState,TResult](FSharpFunc`2 mapping, TState state, FSharpList`1 list) in C:\Users\nojaf\Projects\main-fsharp\src\FSharp.Core\list.fs:line 109
   at FSharp.Compiler.ParseAndCheckInputs.CheckClosedInputSet(CompilationThreadToken ctok, FSharpFunc`2 checkForErrors, TcConfig tcConfig, TcImports tcImports, TcGlobals tcGlobals, FSharpOption`1 prefixPathOpt, TcState tcState, FSharpFunc`2 eagerFormat, FSharpList`1 inputs) in C:\Users\nojaf\Projects\main-fsharp\src\Compiler\Driver\ParseAndCheckInputs.fs:line 1788
   at FSharp.Compiler.Driver.TypeCheck(CompilationThreadToken ctok, TcConfig tcConfig, TcImports tcImports, TcGlobals tcGlobals, DiagnosticsLogger diagnosticsLogger, String assemblyName, TcEnv tcEnv0, FSharpList`1 openDecls0, FSharpList`1 inputs, Exiter exiter) in C:\Users\nojaf\Projects\main-fsharp\src\Compiler\Driver\fsc.fs:line 168
   at FSharp.Compiler.Driver.main1(CompilationThreadToken ctok, String[] argv, LegacyReferenceResolver legacyReferenceResolver, Boolean bannerAlreadyPrinted, ReduceMemoryFlag reduceMemoryUsage, CopyFSharpCoreFlag defaultCopyFSharpCore, Exiter exiter, IDiagnosticsLoggerProvider diagnosticsLoggerProvider, DisposablesTracker disposables) in C:\Users\nojaf\Projects\main-fsharp\src\Compiler\Driver\fsc.fs:line 686
   at FSharp.Compiler.Driver.CompileFromCommandLineArguments(CompilationThreadToken ctok, String[] argv, LegacyReferenceResolver legacyReferenceResolver, Boolean bannerAlreadyPrinted, ReduceMemoryFlag reduceMemoryUsage, CopyFSharpCoreFlag defaultCopyFSharpCore, Exiter exiter, IDiagnosticsLoggerProvider loggerProvider, FSharpOption`1 tcImportsCapture, FSharpOption`1 dynamicAssemblyCreator) in C:\Users\nojaf\Projects\main-fsharp\src\Compiler\Driver\fsc.fs:line 1195
   at FSharp.Compiler.CommandLineMain.main(String[] argv) in C:\Users\nojaf\Projects\main-fsharp\src\fsc\fscmain.fs:line 84

Known workarounds

/

Related information

This still worked for 7.0.400-preview.23272.51, so I believe this is a very recent regression.

Provide any related information (optional):

  • Operating system: Windows
  • .NET Runtime kind: dotnet 7.0.400-preview.23272.51
@vzarytovskii
Copy link
Member

vzarytovskii commented May 28, 2023

This still worked for 7.0.400-preview.23272.51, so I believe this is a very recent regression.

And which one it's not working on? Which one have you tested it on? Does it also not work with fs file only, without fsi?

@nojaf
Copy link
Contributor Author

nojaf commented May 30, 2023

This does not work on the latest main. The signature file is required to draw out the issue.

@vzarytovskii
Copy link
Member

This does not work on the latest main. The signature file is required to draw out the issue.

Yeah, I got it for the main, was wondering if you seen it not working in some preview already. This would narrow it down more.

@vzarytovskii
Copy link
Member

7.0.400-preview.23272.51 is 23414364, something from these broke it:
https://github.com/dotnet/fsharp/compare/main..23414364

@vzarytovskii
Copy link
Member

vzarytovskii commented May 30, 2023

Ok, so, likely it didn't work in 7.0.400-preview.23272.51 either, but assert didn't show, because it's only throwing in debug version of compiler.

Update: yes, it's not working in 7.0.400-preview.23272.51
Update 2: 17.5 branch has this issue
Update 3: 17.4 branch has this issue

@vzarytovskii
Copy link
Member

This is why it's happening:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants