Skip to content

Extern compilation no longer works #15269

@nojaf

Description

@nojaf

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 [email protected](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 [email protected](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 [email protected](CancellationToken ct) in C:\Users\nojaf\Projects\main-fsharp\src\Compiler\Utilities\illib.fs:line 881
   at [email protected](CancellationToken ct)
   at [email protected](CancellationToken ct) in C:\Users\nojaf\Projects\main-fsharp\src\Compiler\Checking\CheckDeclarations.fs:line 5536
   at [email protected](CancellationToken ct)
   at [email protected](CancellationToken ct) in C:\Users\nojaf\Projects\main-fsharp\src\Compiler\Driver\ParseAndCheckInputs.fs:line 1329
   at [email protected](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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions