dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.89k stars 782 forks source link

FSC hard crash, every line in file underlined; just after: Internal error: not an assembly reference (4x) #3509

Closed abelbraaksma closed 7 years ago

abelbraaksma commented 7 years ago

I was experimenting to basically try to resolve an issue that I didn't fully understand (and itself reported here, #3508), and then suddenly, BOOM, everything got red and the system showed a messagebox that the FSC.exe compiler crashed:

screengrabfsccrash

Repro steps

Repro is simple, just copy and paste the code (it's contrived and simplified to showcase this scenario) and run it from with VS2017 (for FSI, see below):

namespace CrashFSC

open System

// debatable code, but it was the minimalist example I could come up 
// with after analysis in the original project
module OhOh =

    type MyByte = MyByte of byte with
        static member inline op_Explicit (MyByte x): int64 = int64 x
        static member inline op_Explicit (MyByte x): double = double x

        static member inline op_Explicit (x: int64): MyByte = MyByte (byte x)
        static member inline op_Explicit (x: float): MyByte = MyByte (byte x)        
        static member inline op_Explicit (MyByte x): 'a = failwith "cannot convert"

    /// testing testing
    let inline ( !>>> ) (a: ^a) min: ^b option =
        if a < (^b : (static member op_Explicit: ^b -> ^a) min)  
            then None
        else    
            Some (^b : (static member op_Explicit: ^a -> ^b) a)

    let inline crashMe (a: ^a) min =
        let (result: MyByte option) = !>>> a min
        result

Expected behavior

FSC should never crash, and "internal error" errors should not show.

Actual behavior

See video: a crash of FSC after at least four repeated errors of "not an assembly reference". The output log shows this:

1>D:\Experiments\CrashFSC.fs(22,5): error FS0073: internal error: not an assembly reference (Failure)
1>D:\Experiments\CrashFSC.fs(5,1): error FS0073: internal error: not an assembly reference (Failure)
1>D:\Experiments\CrashFSC.fs(3,1): error FS0073: internal error: not an assembly reference (Failure)
1>typecheck error FS0192: error : not an assembly reference
1>typecheck error FS0073: error : not an assembly reference (Failure)
1>parameter error FS0192: error : not an assembly reference

Note that:

Known workarounds

None that I know of, except that: be careful with this type of code. However, I have another instance that has similar code (meaning: that uses statically resolved type constraints) that compiles just fine.

Related information

I tested this on several environments:

cartermp commented 7 years ago

@dsyme @KevinRansom This looks rather serious. I can repro this in 15.3.2.

zpodlovics commented 7 years ago

The console build will also fail with .NET Core 2.0 on Ubuntu 16.04 x64:

Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

/tmp/crash/Program.fs(17,16): warning FS0077: Member constraints with the name 'op_Explicit' are given special status by the F# compiler as certain .NET types are implicitly augmented with this member. This may result in runtime failures if you attempt to invoke the member constraint from your own code. [/tmp/crash/crash.fsproj]
/tmp/crash/Program.fs(20,18): warning FS0077: Member constraints with the name 'op_Explicit' are given special status by the F# compiler as certain .NET types are implicitly augmented with this member. This may result in runtime failures if you attempt to invoke the member constraint from your own code. [/tmp/crash/crash.fsproj]
/tmp/crash/Program.fs(22,5): error FS0073: internal error: not an assembly reference (Failure) [/tmp/crash/crash.fsproj]

Build FAILED.

The Mono build fail too (```fsharpc --optimize+ Program.fs) with the following exception stack trace:

 fsharpc --optimize+ Program.fs 
F# Compiler for F# 4.1
Freely distributed under the Apache 2.0 Open Source License

/tmp/crash/Program.fs(17,16): warning FS0077: Member constraints with the name 'op_Explicit' are given special status by the F# compiler as certain .NET types are implicitly augmented with this member. This may result in runtime failures if you attempt to invoke the member constraint from your own code.

/tmp/crash/Program.fs(20,18): warning FS0077: Member constraints with the name 'op_Explicit' are given special status by the F# compiler as certain .NET types are implicitly augmented with this member. This may result in runtime failures if you attempt to invoke the member constraint from your own code.

/tmp/crash/Program.fs(22,5): error FS0073: internal error: not an assembly reference (Failure)

/tmp/crash/Program.fs(5,1): error FS0073: internal error: not an assembly reference (Failure)

/tmp/crash/Program.fs(1,1): error FS0073: internal error: not an assembly reference (Failure)

/tmp/crash/Program.fs(1,1): error FS0073: internal error: not an assembly reference (Failure)

error FS0192: internal error: not an assembly reference

error FS0073: internal error: not an assembly reference (Failure)

error FS0192: internal error: not an assembly reference

Unhandled Exception:
System.Exception: not an assembly reference
  at Microsoft.FSharp.Compiler.AbstractIL.IL+ILScopeRef.get_AssemblyRef () [0x00015] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.Tast+TType.GetAssemblyName () [0x00053] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.NicePrint.makeName@2033 (Microsoft.FSharp.Compiler.Tast+TType t1, Microsoft.FSharp.Compiler.Tastops+DisplayEnv denv, Microsoft.FSharp.Compiler.Tast+TType t) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.NicePrint.minimalStringsOfTwoTypes$cont@2019-1 (Microsoft.FSharp.Compiler.Tastops+DisplayEnv denv, Microsoft.FSharp.Collections.FSharpList`1[T] tpcs, Microsoft.FSharp.Compiler.Tast+TType t2, Microsoft.FSharp.Compiler.Tast+TType t1, Microsoft.FSharp.Core.Unit unitVar) [0x0019a] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.NicePrint.minimalStringsOfTwoTypes$cont@2003 (Microsoft.FSharp.Compiler.Tastops+DisplayEnv denv, Microsoft.FSharp.Collections.FSharpList`1[T] tpcs, Microsoft.FSharp.Compiler.Tast+TType t2, Microsoft.FSharp.Compiler.Tast+TType t1, Microsoft.FSharp.Core.Unit unitVar) [0x0014d] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.NicePrint.minimalStringsOfTwoTypes (Microsoft.FSharp.Compiler.Tastops+DisplayEnv denv, Microsoft.FSharp.Compiler.Tast+TType t1, Microsoft.FSharp.Compiler.Tast+TType t2) [0x00112] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.CompileOps.OutputExceptionR@613 (Microsoft.FSharp.Compiler.ErrorLogger+ErrorStyle errorStyle, System.Text.StringBuilder os, System.Exception error) [0x00c5d] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.CompileOps.OutputPhasedDiagnostic (Microsoft.FSharp.Compiler.ErrorLogger+ErrorStyle errorStyle, System.Text.StringBuilder os, Microsoft.FSharp.Compiler.ErrorLogger+PhasedDiagnostic err, System.Boolean isError) [0x00007] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.CompileOps.report@1535 (System.Boolean showFullPaths, System.Boolean isError, System.String implicitIncludeDir, System.Boolean flattenErrors, Microsoft.FSharp.Compiler.ErrorLogger+ErrorStyle errorStyle, System.Collections.Generic.List`1[T] errors, Microsoft.FSharp.Compiler.ErrorLogger+PhasedDiagnostic err) [0x00040] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.CompileOps.CollectDiagnostic (System.String implicitIncludeDir, System.Boolean showFullPaths, System.Boolean flattenErrors, Microsoft.FSharp.Compiler.ErrorLogger+ErrorStyle errorStyle, System.Boolean warning, Microsoft.FSharp.Compiler.ErrorLogger+PhasedDiagnostic err) [0x00066] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.CompileOps.OutputDiagnostic (System.String implicitIncludeDir, System.Boolean showFullPaths, System.Boolean flattenErrors, Microsoft.FSharp.Compiler.ErrorLogger+ErrorStyle errorStyle, System.Boolean isError, System.Text.StringBuilder os, Microsoft.FSharp.Compiler.ErrorLogger+PhasedDiagnostic err) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.Driver+ConsoleErrorLoggerUpToMaxErrors@111-3.Invoke (System.Text.StringBuilder arg10@, Microsoft.FSharp.Compiler.ErrorLogger+PhasedDiagnostic arg20@) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Core.FSharpFunc`2[T,TResult].InvokeFast[V] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] func, T arg1, TResult arg2) [0x0000d] in <595cf004dff9fae1a745038304f05c59>:0 
  at Microsoft.FSharp.Compiler.Lib.writeViaBufferWithEnvironmentNewLines[a] (System.IO.TextWriter os, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] f, a x) [0x00009] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.Driver+ConsoleErrorLoggerUpToMaxErrors@110-2.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00045] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.CompileOptions.DoWithColor[a] (System.ConsoleColor newColor, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] f) [0x0003b] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.CompileOptions.DoWithErrorColor[a] (System.Boolean isError, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] f) [0x00026] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.Driver+ConsoleErrorLoggerUpToMaxErrors@104.HandleIssue (Microsoft.FSharp.Compiler.CompileOps+TcConfigBuilder tcConfigB, Microsoft.FSharp.Compiler.ErrorLogger+PhasedDiagnostic error, System.Boolean isError) [0x0000a] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.Driver+ErrorLoggerUpToMaxErrors.DiagnosticSink (Microsoft.FSharp.Compiler.ErrorLogger+PhasedDiagnostic err, System.Boolean isError) [0x00086] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+chkErrorLogger@411[a].DiagnosticSink (Microsoft.FSharp.Compiler.ErrorLogger+PhasedDiagnostic phasedError, System.Boolean isError) [0x00012] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.CompileOps+ErrorLoggerFilteringByScopedPragmas.DiagnosticSink (Microsoft.FSharp.Compiler.ErrorLogger+PhasedDiagnostic phasedError, System.Boolean isError) [0x00004] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+chkErrorLogger@411[a].DiagnosticSink (Microsoft.FSharp.Compiler.ErrorLogger+PhasedDiagnostic phasedError, System.Boolean isError) [0x00012] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorR (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn) [0x00025] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.Error[b] (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger.CommitOperationResult[a] (Microsoft.FSharp.Compiler.ErrorLogger+OperationResult`1[T] res) [0x0002a] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.TypeChecker+GeneralizationHelpers.CanonicalizePartialInferenceProblem (Microsoft.FSharp.Compiler.TypeChecker+cenv cenv, Microsoft.FSharp.Compiler.Tastops+DisplayEnv denv, Microsoft.FSharp.Compiler.Range+range m, Microsoft.FSharp.Collections.FSharpList`1[T] tps) [0x00027] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.TypeChecker.TcLetBinding (Microsoft.FSharp.Compiler.TypeChecker+cenv cenv, System.Boolean isUse, Microsoft.FSharp.Compiler.TypeChecker+TcEnv env, Microsoft.FSharp.Compiler.TypeChecker+ContainerInfo containerInfo, Microsoft.FSharp.Compiler.TypeChecker+DeclKind declKind, Microsoft.FSharp.Compiler.TypeChecker+SyntacticUnscopedTyparEnv tpenv, Microsoft.FSharp.Collections.FSharpList`1[T] binds, Microsoft.FSharp.Compiler.Range+range bindsm, Microsoft.FSharp.Compiler.Range+range scopem) [0x00047] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.TypeChecker.TcLetBindings (Microsoft.FSharp.Compiler.TypeChecker+cenv cenv, Microsoft.FSharp.Compiler.TypeChecker+TcEnv env, Microsoft.FSharp.Compiler.TypeChecker+ContainerInfo containerInfo, Microsoft.FSharp.Compiler.TypeChecker+DeclKind declKind, Microsoft.FSharp.Compiler.TypeChecker+SyntacticUnscopedTyparEnv tpenv, Microsoft.FSharp.Collections.FSharpList`1[T] binds, Microsoft.FSharp.Compiler.Range+range bindsm, Microsoft.FSharp.Compiler.Range+range scopem) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.TypeChecker+TcModuleOrNamespaceElementNonMutRec@16373-1.Invoke (Microsoft.FSharp.Core.Unit unitVar) [0x00345] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+delay@906-1[T].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken _ctok) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+catch@900-1[a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00002] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x000d2] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.TypeChecker+TcModuleOrNamespaceElementNonMutRec@16372-18.Invoke (System.Exception _arg3) [0x00012] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+tryWith@917-1[a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+ResultOrException`1[TResult] _arg1) [0x00010] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule.bind[a,b] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] k, Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+Eventually`1[T] e) [0x0002b] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00013] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+catch@900-1[a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00002] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x000d2] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.TypeChecker+TcModuleOrNamespaceElementNonMutRec@16372-18.Invoke (System.Exception _arg3) [0x00012] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+tryWith@917-1[a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+ResultOrException`1[TResult] _arg1) [0x00010] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule.bind[a,b] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] k, Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+Eventually`1[T] e) [0x0002b] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00013] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+catch@900-1[a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00002] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x000d2] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.TypeChecker+TcModuleOrNamespaceElementNonMutRec@16372-18.Invoke (System.Exception _arg3) [0x00012] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+tryWith@917-1[a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+ResultOrException`1[TResult] _arg1) [0x00010] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule.bind[a,b] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] k, Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+Eventually`1[T] e) [0x0002b] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00013] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+catch@900-1[a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00002] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x000d2] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.TypeChecker+TcModuleOrNamespaceElementNonMutRec@16372-18.Invoke (System.Exception _arg3) [0x00012] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+tryWith@917-1[a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+ResultOrException`1[TResult] _arg1) [0x00010] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule.bind[a,b] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] k, Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+Eventually`1[T] e) [0x0002b] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00013] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+catch@900-1[a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00002] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x000d2] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.CompileOps+TypeCheckOneInputEventually@5203-13.Invoke (System.Exception _arg5) [0x0000c] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+tryWith@917-1[a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+ResultOrException`1[TResult] _arg1) [0x00010] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule.bind[a,b] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] k, Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+Eventually`1[T] e) [0x0002b] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule+bind@891-1[b,a].Invoke (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok) [0x00013] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule.forceWhile[a] (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] check, Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+Eventually`1[T] e) [0x00022] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+EventuallyModule.force[a] (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok, Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+Eventually`1[T] e) [0x00007] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.CompileOps.TypeCheckOneInput (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] checkForErrors, Microsoft.FSharp.Compiler.CompileOps+TcConfig tcConfig, Microsoft.FSharp.Compiler.CompileOps+TcImports tcImports, Microsoft.FSharp.Compiler.TcGlobals+TcGlobals tcGlobals, Microsoft.FSharp.Core.FSharpOption`1[T] prefixPathOpt, Microsoft.FSharp.Compiler.CompileOps+TcState tcState, Microsoft.FSharp.Compiler.Ast+ParsedInput inp) [0x00030] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.CompileOps+TypeCheckMultipleInputs@5333.Invoke (Microsoft.FSharp.Compiler.CompileOps+TcState tcState, Microsoft.FSharp.Compiler.Ast+ParsedInput inp) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+List.mapFold[a,b,c] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] f, a s, Microsoft.FSharp.Collections.FSharpList`1[T] l) [0x00026] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.CompileOps.TypeCheckMultipleInputs (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] checkForErrors, Microsoft.FSharp.Compiler.CompileOps+TcConfig tcConfig, Microsoft.FSharp.Compiler.CompileOps+TcImports tcImports, Microsoft.FSharp.Compiler.TcGlobals+TcGlobals tcGlobals, Microsoft.FSharp.Core.FSharpOption`1[T] prefixPathOpt, Microsoft.FSharp.Compiler.CompileOps+TcState tcState, Microsoft.FSharp.Collections.FSharpList`1[T] inputs) [0x0000e] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.CompileOps.TypeCheckClosedInputSet (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] checkForErrors, Microsoft.FSharp.Compiler.CompileOps+TcConfig tcConfig, Microsoft.FSharp.Compiler.CompileOps+TcImports tcImports, Microsoft.FSharp.Compiler.TcGlobals+TcGlobals tcGlobals, Microsoft.FSharp.Core.FSharpOption`1[T] prefixPathOpt, Microsoft.FSharp.Compiler.CompileOps+TcState tcState, Microsoft.FSharp.Collections.FSharpList`1[T] inputs) [0x00001] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.Driver.TypeCheck (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok, Microsoft.FSharp.Compiler.CompileOps+TcConfig tcConfig, Microsoft.FSharp.Compiler.CompileOps+TcImports tcImports, Microsoft.FSharp.Compiler.TcGlobals+TcGlobals tcGlobals, Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger errorLogger, System.String assemblyName, Microsoft.FSharp.Compiler.Ast+NiceNameGenerator niceNameGen, Microsoft.FSharp.Compiler.TypeChecker+TcEnv tcEnv0, Microsoft.FSharp.Collections.FSharpList`1[T] inputs, Microsoft.FSharp.Compiler.ErrorLogger+Exiter exiter) [0x0004b] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x000d2] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.Driver.TypeCheck (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok, Microsoft.FSharp.Compiler.CompileOps+TcConfig tcConfig, Microsoft.FSharp.Compiler.CompileOps+TcImports tcImports, Microsoft.FSharp.Compiler.TcGlobals+TcGlobals tcGlobals, Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger errorLogger, System.String assemblyName, Microsoft.FSharp.Compiler.Ast+NiceNameGenerator niceNameGen, Microsoft.FSharp.Compiler.TypeChecker+TcEnv tcEnv0, Microsoft.FSharp.Collections.FSharpList`1[T] inputs, Microsoft.FSharp.Compiler.ErrorLogger+Exiter exiter) [0x0006b] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.Driver.main0[a] (a ctok, System.String[] argv, Microsoft.FSharp.Compiler.ReferenceResolver+Resolver referenceResolver, System.Boolean bannerAlreadyPrinted, Microsoft.FSharp.Compiler.ErrorLogger+Exiter exiter, Microsoft.FSharp.Compiler.Driver+ErrorLoggerProvider errorLoggerProvider, Microsoft.FSharp.Compiler.Driver+DisposablesTracker disposables) [0x0049c] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.Driver.typecheckAndCompile (System.String[] argv, Microsoft.FSharp.Compiler.ReferenceResolver+Resolver referenceResolver, System.Boolean bannerAlreadyPrinted, Microsoft.FSharp.Compiler.ErrorLogger+Exiter exiter, Microsoft.FSharp.Compiler.Driver+ErrorLoggerProvider loggerProvider) [0x0000f] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.Driver.mainCompile (System.String[] argv, Microsoft.FSharp.Compiler.ReferenceResolver+Resolver referenceResolver, System.Boolean bannerAlreadyPrinted, Microsoft.FSharp.Compiler.ErrorLogger+Exiter exiter) [0x0000a] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.CommandLineMain+Driver.main (System.String[] argv) [0x0002e] in <595cf089c960099ba745038389f05c59>:0 
  at Microsoft.FSharp.Compiler.CommandLineMain.main (System.String[] argv) [0x00042] in <595cf089c960099ba745038389f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x000d2] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.ErrorLogger.errorRecovery (System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x00006] in <595cf0767f81fe20a745038376f05c59>:0 
  at Microsoft.FSharp.Compiler.CommandLineMain.main (System.String[] argv) [0x00056] in <595cf089c960099ba745038389f05c59>:0 
abelbraaksma commented 7 years ago

@zpodlovics: thanks for the stacktrace. So it looks like it tries to load a referenced assembly that either isn't referenced or simply doesn't exist.

@KevinRansom, @cartermp, @dsyme, I now have more info after further analysis and a plu/minus one-character you can use to repro, see below (sorry for the long text).

I think the root cause might be in the way the compiler tries to resolve static member constraints that involve op_Explicit (and similarly perhaps op_Implicit or other ops). I found that, to make this code work as I wanted it to work, it needed to be rewritten as follows:

namespace CrashFSC
open System
module OhOh =

    type MyByte = MyByte of byte with
        static member inline op_Explicit (MyByte x): int64 = int64 x
        static member inline op_Explicit (MyByte x): double = double x

        static member inline op_Explicit (x: int64): MyByte = MyByte (byte x)
        static member inline op_Explicit (x: float): MyByte = MyByte (byte x)        

    /// testing testing
    let inline ( !>>> ) (a: ^a) min: ^b option =
        if a < ((^a or ^b) : (static member op_Explicit: ^b -> ^a) min)  
            then None
        else    
            Some ((^a or ^b) : (static member op_Explicit: ^a -> ^b) a)

    let inline crashMe (a: ^a) min =
        let (result: MyByte option) = !>>> a min
        result

    let testMe() =
        crashMe 12L (MyByte 15uy), crashMe 12. (MyByte 0uy), crashMe 12L (MyByte 0uy)

Now, if you merely copy/paste this, it will work, and calling testMe() will execute as might be expected (testing agains a minimum value and returning Some/None):

> OhOh.testMe();;
val it : OhOh.MyByte option * OhOh.MyByte option * OhOh.MyByte option =
  (None, Some (MyByte 12uy), Some (MyByte 12uy))

However, it is impossible to type this code without getting the error!. See:

screengrabfsccrashvalidcode

Some thoughts:

dsyme commented 7 years ago

Yes, there is a warning that op_Explicit has special treatment:


/tmp/crash/Program.fs(17,16): warning FS0077: Member constraints with the name 'op_Explicit' are given special status by the F# compiler as certain .NET types are implicitly augmented with this member. This may result in runtime failures if you attempt to invoke the member constraint from your own code. [/tmp/crash/crash.fsproj]
/tmp/crash/Program.fs(20,18): warning FS0077: Member constraints with the name 'op_Explicit' are given special status by the F# compiler as certain .NET types are implicitly augmented with this member. This may result in runtime failures if you attempt to invoke the member constraint from your own code. [/tmp/crash/crash.fsproj]

The compiler shouldn't crash. But equally, this scenario is basically unsupported in any case

abelbraaksma commented 7 years ago

@dsyme, it also crashes when you use op_Implicit, which does not give that warning:

Repro with op_Implicit

module OhOh =

    type MyByte = MyByte of byte with
        static member inline op_Implicit (MyByte x): int64 = int64 x
        static member inline op_Implicit (MyByte x): double = double x

        static member inline op_Implicit (x: int64): MyByte = MyByte (byte x)
        static member inline op_Implicit (x: float): MyByte = MyByte (byte x)        
        static member inline op_Implicit (MyByte x): 'a = failwith "cannot convert"

    /// testing testing
    let inline ( !>>> ) (a: ^a) min: ^b option =
        if a < (^b : (static member op_Implicit: ^b -> ^a) min)  
            then None
        else    
            Some (^b : (static member op_Implicit: ^a -> ^b) a)

    let inline crashMe (a: ^a) min =
        let (result: MyByte option) = !>>> a min
        result

Crash:

image

Output from compiler before the crash:

1>D:\Projects\Exselt\Experiments\CrashFSC.fs(23,5): error FS0073: internal error: not an assembly reference (Failure)
1>D:\Projects\Exselt\Experiments\CrashFSC.fs(6,1): error FS0073: internal error: not an assembly reference (Failure)
1>D:\Projects\Exselt\Experiments\CrashFSC.fs(3,1): error FS0073: internal error: not an assembly reference (Failure)
1>typecheck error FS0192: error : not an assembly reference
1>typecheck error FS0073: error : not an assembly reference (Failure)
1>parameter error FS0192: error : not an assembly reference

It looks similar to the problem mentioned in #3508, as the hard crash goes away and it compiles just fine if you change the static member call syntax to use (^a or ^b) static member ... instead of just ^a static member .... This was shown in my previous comment.

However, even then, it still crashes when you just type the code. And that crash, too, happens with op_Implicit as well (so no warning to mark this "unsupported").

Repro with valid code while typing

Here's a repro of that last one (deliberately stopped halfway typing 12L (MyByte 15uy) at the end, as that is where I got the first crash again:

module OhOh =

    type MyByte = MyByte of byte with
        static member inline op_Implicit (MyByte x): int64 = int64 x
        static member inline op_Implicit (MyByte x): double = double x

        static member inline op_Implicit (x: int64): MyByte = MyByte (byte x)
        static member inline op_Implicit (x: float): MyByte = MyByte (byte x)        

    /// testing testing
    let inline ( !>>> ) (a: ^a) min: ^b option =
        if a < ((^a or ^b) : (static member op_Implicit: ^b -> ^a) min)  
            then None
        else    
            Some ((^a or ^b) : (static member op_Implicit: ^a -> ^b) a)

    let inline crashMe (a: ^a) min =
        let (result: MyByte option) = !>>> a min
        result

    let testme() =
        crashMe 1
dsyme commented 7 years ago

Compiler crash is fixed by linked PR

abelbraaksma commented 7 years ago

@dsyme, wow, that was quick! I'll check it as soon as the next nightly is deployed and available.

dsyme commented 7 years ago

Fixed

abelbraaksma commented 7 years ago

@dsyme, in the most recent nightlies, it doesn't look so red anymore, but it still crashes the FSC. So it seems like something's fixed, but not everything. Perhaps reopen? Or am I testing too soon?

image

dsyme commented 7 years ago

@abelbraaksma When you install a nightly, it sadly doesn't yet change the actual fsc.exe used when building from Visual Studio, see DEVGUIDE.md. You have to set FscToolPath explicitly in your projct file to a whacky path under "c:\user\me\AppData..." where the extension is installed

@cartermp @KevinRansom @brettfo We should fix this somehow. I think someone said Roslyn has a hack in the targets file for this case?

KevinRansom commented 7 years ago

Yes ... one of these days we will eliminate the Microsoft SDK installs of F#, it's not that it's hard. It just takes effort. And un-appetizing as it currently is, it works ... and there are still a lot of not-working things to get to first.

dsyme commented 7 years ago

Yes ... one of these days we will eliminate the Microsoft SDK installs of F#

Is that the only way to get the nightly compiler used in preference to the SDK?

dsyme commented 7 years ago

Yes ... one of these days we will eliminate the Microsoft SDK installs of F#

Also, what would that mean for the build tool installations (i.e. installations without Visual Studio). Where would the F# compiler actually be installed?

I assume we also have a similar issue with the .NET SDK install of the compiler

KevinRansom commented 7 years ago

Well I assume they would use the BuildTools installer ... which installs msbuild and so installs much like VS just in a different named directory.

https://www.visualstudio.com/downloads/

go to the bottom of the page and click on Build tools for VS2017 ---- It installs msbuild and F#, and whatever you need ... image

Select F# https://www.visualstudio.com/downloads/

image

Installation will eventually ... not now because of Microsoft sdk ... we would install below build tools...

Make sense?

abelbraaksma commented 7 years ago

You have to set FscToolPath explicitly in your projct file to a whacky path under "c:\user\me\AppData..." where the extension is installed

@dsyme, wait, are you saying that all this time I have been testing against older versions of fsc.exe? We should then probably add a big warning to the https://blogs.msdn.microsoft.com/dotnet/2017/03/14/announcing-nightly-releases-for-the-visual-f-tools/ page, as I'm probably not the only one thinking "hurray, just install the VSIX and all my F#-related tools are now updated". Btw, I thought I had read the devguide.md, but must have skipped over this part.

Or do you mean to say that after installing a new VS Preview it overrides whatever the nightly has set? Cause in that case, I could just reinstall the nightly.

@KevinRansom, I don't fully understand your latest comment. That looks like standard installation of VS + F# to me. It is probably not insanely difficult to try to find the location where fsc.exe is set (guess it's some *.target file) and update it manually so that VS from then on uses the nightly instead.

abelbraaksma commented 7 years ago

Btw, I thought I had read the devguide.md, but must have skipped over this part.

Actually, I don't see any mention there about installing the nightly and having to set / change the location for fsc.exe. There's a section on "Clobber the F# SDK", but this seems to be related to using whatever you are currently building. But I used the VSIX from here: https://dotnet.myget.org/feed/fsharp/package/vsix/VisualFSharp

KevinRansom commented 7 years ago

@abelbraaksma the nightly is a VSIX, it doesn't carry fsc.exe.

The initial goal for nightlies was to get eyes on the amazing amount of IDE work that Vasily, Saul, Don and a few others were doing earlier in the year.

We need to get around to adding the compiler to the VSIX deployment, and dropping the Microsoft SDK install location for the compiler. Once we do that, then F5 deployment and the nightlies will safely replace the compiler. But right now that is not what happens.

abelbraaksma commented 7 years ago

@KevinRansom, if that could be done, that would be awesome! I don't know how many people have made the same (wrong) assumptions I did, but even if we improve on informing them, it would make a big difference in early-adoption testing if the FSC.exe could become part of the VSIX. I have no idea what it would take to do so (sorry, never made a VSIX myself), but having it would be a big win in many ways.

Perhaps we should take this (new) thread into a new issue?

dsyme commented 7 years ago

@abelbraaksma the nightly is a VSIX, it doesn't carry fsc.exe.

You're right, fsc.exe is not installed into the extension directory, e.g. C:\Users\dsyme\AppData\Local\Microsoft\VisualStudio\15.0_80d64992\Extensions\ao1tjmmj.34g on my machine right now.

dsyme commented 7 years ago

We need to get around to adding the compiler to the VSIX deployment, and dropping the Microsoft SDK install location for the compiler. Once we do that, then F5 deployment and the nightlies will safely replace the compiler.

In this scenario, how will the targets entry in the project file be redirected to use the VSIX-installed deployment?

<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
abelbraaksma commented 7 years ago

In this scenario, how will the targets entry in the project file be redirected to use the VSIX-installed deployment?

<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>

@dsyme, Can we update that definition? For instance, I believe this could work (the parameter and its value TBD):

<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
<FSharpTargetsPath Condition=" '$(VisualFSharpNightly)' == 'defined' ">$(VisualFSharpNightlyPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
KevinRansom commented 7 years ago

@dsyme ... we will have to make everything work ... there is the build task, the targets, and the compiler. Actually doing it will be fairly easy. The least appealing part is to make the multi-targeting properties work on the properties dialog. That and the bug tail ...

KevinRansom commented 7 years ago

@dsyme to answer your direct question ... we already drop shims to forward to the targets file ... they will need some manipulation ... possibly that will be slightly tricky because the deployment directories name is a random guid.

KevinRansom commented 7 years ago

Compared, however, to getting loc done in the OSS build, getting the build off of project .json, getting dotnet sdk projects working in the ide. Enabling FSI in coreclr, adding package management to FSI, Large project load performance ... this is kind of at the lower end of priorities right now.

However, it might well ... make an interesting weekend project.

dsyme commented 7 years ago

possibly that will be slightly tricky because the deployment directories name is a random guid.

Yes, that's what I'm asking about - I don't know a solution to that?

abelbraaksma commented 7 years ago

@dsyme, @KevinRansom, since we are all developers here, would a temporary solution be to create a *.cmd file, or *.ps script that can download the latest FSC.exe and set the correct params? This could then be linked in the DEVGUIDE.md and TESTGUIDE.md so that people are going to actually use the correct versions when to try to test the resolution of a bug.

Or, on top of that, add a warning to the VSIX install experience, something like:

To use this nightly with the latest F# compiler, you will need to fix setting so and so, or download script so and so, otherwise the predefined compiler of the latest RTM or VS Preview will be used.

abelbraaksma commented 6 years ago

Just a heads up for posterity: this now works as expected and gives a compile-time error without crashing FSC. Tested in 15.8 P2.