Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Compiler/CodeGen/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6806,10 +6806,12 @@ and GetIlxClosureFreeVars cenv m (thisVars: ValRef list) boxity eenvouter takenN
// Collect the free variables of the closure
let cloFreeVarResults =
let opts = CollectTyparsAndLocalsWithStackGuard()

let opts =
match eenvouter.tyenv.TemplateReplacement with
| None -> opts
| Some (tcref, _, typars, _) -> opts.WithTemplateReplacement(tyconRefEq g tcref, typars)

freeInExpr opts expr

// Partition the free variables when some can be accessed from places besides the immediate environment
Expand Down
98 changes: 55 additions & 43 deletions src/Compiler/Driver/CompilerOptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -261,31 +261,40 @@ let ParseCompilerOptions (collectOtherArgument: string -> unit, blocks: Compiler

let specs = List.collect GetOptionsOfBlock blocks

// returns a tuple - the option token, the option argument string
let parseOption (s: string) =
// grab the option token
let opts = s.Split([| ':' |])
let mutable opt = opts[0]

if opt = "" then
()
// if it doesn't start with a '-' or '/', reject outright
elif opt[0] <> '-' && opt[0] <> '/' then
opt <- ""
elif opt <> "--" then
// is it an abbreviated or MSFT-style option?
// if so, strip the first character and move on with your life
if opt.Length = 2 || isSlashOpt opt then
opt <- opt[1..]
// else, it should be a non-abbreviated option starting with "--"
elif opt.Length > 3 && opt.StartsWithOrdinal("--") then
opt <- opt[2..]
// returns a tuple - the option minus switchchars, the option tokenand the option argument string
let parseOption (option: string) =

// Get option arguments, I.e everything following first:
let opts = option.Split([| ':' |])
let optArgs = String.Join(":", opts[1..])

let opt =
if option = "" then
""
// if it doesn't start with a '-' or '/', reject outright
elif option[0] <> '-' && option[0] <> '/' then
""
elif option <> "--" then
// is it an abbreviated or MSFT-style option?
// if so, strip the first character and move on with your life
// Wierdly a -- option can't have only a 1 character name
if option.Length = 2 || isSlashOpt option then
option[1..]
elif option.Length >= 3 && option[2] = ':' then
option[1..]
elif option.StartsWithOrdinal("--") then
match option.Length with
| l when l >= 4 && option[3] = ':' -> ""
| l when l > 3 -> option[2..]
| _ -> ""
else
""
else
opt <- ""
option

// get the argument string
let optArgs = if opts.Length > 1 then String.Join(":", opts[1..]) else ""
opt, optArgs
// grab the option token
let token = opt.Split([| ':' |])[0]
opt, token, optArgs

let getOptionArg compilerOption (argString: string) =
if argString = "" then
Expand Down Expand Up @@ -352,7 +361,7 @@ let ParseCompilerOptions (collectOtherArgument: string -> unit, blocks: Compiler

processArg (responseFileOptions @ t)
| opt :: t ->
let optToken, argString = parseOption opt
let option, optToken, argString = parseOption opt

let reportDeprecatedOption errOpt =
match errOpt with
Expand All @@ -361,7 +370,7 @@ let ParseCompilerOptions (collectOtherArgument: string -> unit, blocks: Compiler

let rec attempt l =
match l with
| CompilerOption (s, _, OptionConsoleOnly f, d, _) :: _ when optToken = s && argString = "" ->
| CompilerOption (s, _, OptionConsoleOnly f, d, _) :: _ when option = s ->
reportDeprecatedOption d
f blocks
t
Expand Down Expand Up @@ -710,7 +719,7 @@ let tagAlgorithm = "{SHA1|SHA256}"
let tagInt = "<n>"
let tagPathMap = "<path=sourcePath;...>"
let tagNone = ""
let tagLangVersionValues = "{?|version|latest|preview}"
let tagLangVersionValues = "{version|latest|preview}"

// PrintOptionInfo
//----------------
Expand Down Expand Up @@ -1104,23 +1113,16 @@ let mlCompatibilityFlag (tcConfigB: TcConfigBuilder) =
Some(FSComp.SR.optsMlcompatibility ())
)

/// LanguageVersion management
let setLanguageVersion specifiedVersion =

let dumpAllowedValues () =
printfn "%s" (FSComp.SR.optsSupportedLangVersions ())

for v in LanguageVersion.ValidOptions do
printfn "%s" v

for v in LanguageVersion.ValidVersions do
printfn "%s" v

exit 0
let GetLanguageVersions () =
seq {
FSComp.SR.optsSupportedLangVersions ()
yield! LanguageVersion.ValidOptions
yield! LanguageVersion.ValidVersions
}
|> String.concat Environment.NewLine

if specifiedVersion = "?" then
dumpAllowedValues ()
elif specifiedVersion.ToUpperInvariant() = "PREVIEW" then
let setLanguageVersion (specifiedVersion: string) =
if specifiedVersion.ToUpperInvariant() = "PREVIEW" then
()
elif not (LanguageVersion.ContainsVersion specifiedVersion) then
error (Error(FSComp.SR.optsUnrecognizedLanguageVersion specifiedVersion, rangeCmdArgs))
Expand All @@ -1130,6 +1132,16 @@ let setLanguageVersion specifiedVersion =
let languageFlags tcConfigB =
[
// -langversion:? Display the allowed values for language version
CompilerOption(
"langversion:?",
tagNone,
OptionConsoleOnly(fun _ ->
Console.Write(GetLanguageVersions())
exit 0),
None,
Some(FSComp.SR.optsGetLangVersions ())
)

// -langversion:<string> Specify language version such as
// 'default' (latest major version), or
// 'latest' (latest version, including minor versions),
Expand All @@ -1140,7 +1152,7 @@ let languageFlags tcConfigB =
tagLangVersionValues,
OptionString(fun switch -> tcConfigB.langVersion <- setLanguageVersion (switch)),
None,
Some(FSComp.SR.optsLangVersion ())
Some(FSComp.SR.optsSetLangVersion ())
)

CompilerOption(
Expand Down
2 changes: 2 additions & 0 deletions src/Compiler/Driver/CompilerOptions.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ val GetHelpFsc: tcConfigB: TcConfigBuilder -> blocks: CompilerOptionBlock list -

val GetVersion: tcConfigB: TcConfigBuilder -> string

val GetLanguageVersions: unit -> string

val GetCoreFscCompilerOptions: TcConfigBuilder -> CompilerOptionBlock list

val GetCoreFsiCompilerOptions: TcConfigBuilder -> CompilerOptionBlock list
Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,8 @@ notAFunctionButMaybeDeclaration,"This value is not a function and cannot be appl
3353,chkFeatureNotSupportedInLibrary,"Feature '%s' requires the F# library for language version %s or greater."
3360,parsEqualsMissingInTypeDefinition,"Unexpected token in type definition. Expected '=' after the type '%s'."
useSdkRefs,"Use reference assemblies for .NET framework references when available (Enabled by default)."
optsLangVersion,"Display the allowed values for language version, specify language version such as 'latest' or 'preview'"
optsGetLangVersions,"Display the allowed values for language version."
optsSetLangVersion,"Specify language version such as 'latest' or 'preview'."
optsSupportedLangVersions,"Supported language versions:"
nativeResourceFormatError,"Stream does not begin with a null resource and is not in '.RES' format."
nativeResourceHeaderMalformed,"Resource header beginning at offset %s is malformed."
Expand Down
15 changes: 10 additions & 5 deletions src/Compiler/xlf/FSComp.txt.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,11 @@
<target state="new">Compress interface and optimization data files</target>
<note />
</trans-unit>
<trans-unit id="optsGetLangVersions">
<source>Display the allowed values for language version.</source>
<target state="new">Display the allowed values for language version.</target>
<note />
</trans-unit>
<trans-unit id="optsInvalidRefAssembly">
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
<target state="translated">Neplatné použití generování referenčního sestavení, nepoužívejte --staticlink ani --refonly a --refout společně.</target>
Expand All @@ -487,11 +492,6 @@
<target state="translated">Neplatná cesta k referenčnímu sestavení</target>
<note />
</trans-unit>
<trans-unit id="optsLangVersion">
<source>Display the allowed values for language version, specify language version such as 'latest' or 'preview'</source>
<target state="translated">Zobrazte si povolené hodnoty verze jazyka a pak zadejte požadovanou verzi, například latest nebo preview.</target>
<note />
</trans-unit>
<trans-unit id="optsOptimizationData">
<source>Specify included optimization information, the default is file. Important for distributed libraries.</source>
<target state="new">Specify included optimization information, the default is file. Important for distributed libraries.</target>
Expand All @@ -517,6 +517,11 @@
<target state="new">Disable implicit generation of constructs using reflection</target>
<note />
</trans-unit>
<trans-unit id="optsSetLangVersion">
<source>Specify language version such as 'latest' or 'preview'.</source>
<target state="new">Specify language version such as 'latest' or 'preview'.</target>
<note />
</trans-unit>
<trans-unit id="optsSignatureData">
<source>Include F# interface information, the default is file. Essential for distributing libraries.</source>
<target state="new">Include F# interface information, the default is file. Essential for distributing libraries.</target>
Expand Down
15 changes: 10 additions & 5 deletions src/Compiler/xlf/FSComp.txt.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,11 @@
<target state="new">Compress interface and optimization data files</target>
<note />
</trans-unit>
<trans-unit id="optsGetLangVersions">
<source>Display the allowed values for language version.</source>
<target state="new">Display the allowed values for language version.</target>
<note />
</trans-unit>
<trans-unit id="optsInvalidRefAssembly">
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
<target state="translated">Ungültige Verwendung der Ausgabe einer Referenzassembly. Verwenden Sie nicht "--staticlink" oder "--refonly" und "--refout" zusammen.</target>
Expand All @@ -487,11 +492,6 @@
<target state="translated">Ungültiger Referenzassemblypfad"</target>
<note />
</trans-unit>
<trans-unit id="optsLangVersion">
<source>Display the allowed values for language version, specify language version such as 'latest' or 'preview'</source>
<target state="translated">Zeigen Sie die zulässigen Werte für die Sprachversion an. Geben Sie die Sprachversion als "latest" oder "preview" an.</target>
<note />
</trans-unit>
<trans-unit id="optsOptimizationData">
<source>Specify included optimization information, the default is file. Important for distributed libraries.</source>
<target state="new">Specify included optimization information, the default is file. Important for distributed libraries.</target>
Expand All @@ -517,6 +517,11 @@
<target state="new">Disable implicit generation of constructs using reflection</target>
<note />
</trans-unit>
<trans-unit id="optsSetLangVersion">
<source>Specify language version such as 'latest' or 'preview'.</source>
<target state="new">Specify language version such as 'latest' or 'preview'.</target>
<note />
</trans-unit>
<trans-unit id="optsSignatureData">
<source>Include F# interface information, the default is file. Essential for distributing libraries.</source>
<target state="new">Include F# interface information, the default is file. Essential for distributing libraries.</target>
Expand Down
15 changes: 10 additions & 5 deletions src/Compiler/xlf/FSComp.txt.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,11 @@
<target state="new">Compress interface and optimization data files</target>
<note />
</trans-unit>
<trans-unit id="optsGetLangVersions">
<source>Display the allowed values for language version.</source>
<target state="new">Display the allowed values for language version.</target>
<note />
</trans-unit>
<trans-unit id="optsInvalidRefAssembly">
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
<target state="translated">Uso no válido de emitir un ensamblado de referencia, no use "--staticlink', or '--refonly' and '--refout" de forma conjunta.</target>
Expand All @@ -487,11 +492,6 @@
<target state="translated">Ruta de acceso de ensamblado de referencia no válida</target>
<note />
</trans-unit>
<trans-unit id="optsLangVersion">
<source>Display the allowed values for language version, specify language version such as 'latest' or 'preview'</source>
<target state="translated">Mostrar los valores permitidos para la versión de idioma, especificar la versión de idioma como "latest" "preview"</target>
<note />
</trans-unit>
<trans-unit id="optsOptimizationData">
<source>Specify included optimization information, the default is file. Important for distributed libraries.</source>
<target state="new">Specify included optimization information, the default is file. Important for distributed libraries.</target>
Expand All @@ -517,6 +517,11 @@
<target state="new">Disable implicit generation of constructs using reflection</target>
<note />
</trans-unit>
<trans-unit id="optsSetLangVersion">
<source>Specify language version such as 'latest' or 'preview'.</source>
<target state="new">Specify language version such as 'latest' or 'preview'.</target>
<note />
</trans-unit>
<trans-unit id="optsSignatureData">
<source>Include F# interface information, the default is file. Essential for distributing libraries.</source>
<target state="new">Include F# interface information, the default is file. Essential for distributing libraries.</target>
Expand Down
15 changes: 10 additions & 5 deletions src/Compiler/xlf/FSComp.txt.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,11 @@
<target state="new">Compress interface and optimization data files</target>
<note />
</trans-unit>
<trans-unit id="optsGetLangVersions">
<source>Display the allowed values for language version.</source>
<target state="new">Display the allowed values for language version.</target>
<note />
</trans-unit>
<trans-unit id="optsInvalidRefAssembly">
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
<target state="translated">Utilisation non valide de l’émission d’un assembly de référence. N’utilisez pas '--staticlink' ni '--refonly' et '--refout' ensemble.</target>
Expand All @@ -487,11 +492,6 @@
<target state="translated">Chemin d'assemblage de référence non valide'</target>
<note />
</trans-unit>
<trans-unit id="optsLangVersion">
<source>Display the allowed values for language version, specify language version such as 'latest' or 'preview'</source>
<target state="translated">Afficher les valeurs autorisées pour la version du langage, spécifier la version du langage comme 'dernière' ou 'préversion'</target>
<note />
</trans-unit>
<trans-unit id="optsOptimizationData">
<source>Specify included optimization information, the default is file. Important for distributed libraries.</source>
<target state="new">Specify included optimization information, the default is file. Important for distributed libraries.</target>
Expand All @@ -517,6 +517,11 @@
<target state="new">Disable implicit generation of constructs using reflection</target>
<note />
</trans-unit>
<trans-unit id="optsSetLangVersion">
<source>Specify language version such as 'latest' or 'preview'.</source>
<target state="new">Specify language version such as 'latest' or 'preview'.</target>
<note />
</trans-unit>
<trans-unit id="optsSignatureData">
<source>Include F# interface information, the default is file. Essential for distributing libraries.</source>
<target state="new">Include F# interface information, the default is file. Essential for distributing libraries.</target>
Expand Down
15 changes: 10 additions & 5 deletions src/Compiler/xlf/FSComp.txt.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,11 @@
<target state="new">Compress interface and optimization data files</target>
<note />
</trans-unit>
<trans-unit id="optsGetLangVersions">
<source>Display the allowed values for language version.</source>
<target state="new">Display the allowed values for language version.</target>
<note />
</trans-unit>
<trans-unit id="optsInvalidRefAssembly">
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
<target state="translated">Utilizzo non valido della creazione di un assembly di riferimento. Non usare insieme '--staticlink' o '--refonly' e '--refout'.</target>
Expand All @@ -487,11 +492,6 @@
<target state="translated">Percorso assembly di riferimento non valido'</target>
<note />
</trans-unit>
<trans-unit id="optsLangVersion">
<source>Display the allowed values for language version, specify language version such as 'latest' or 'preview'</source>
<target state="translated">Visualizza i valori consentiti per la versione del linguaggio. Specificare la versione del linguaggio, ad esempio 'latest' o 'preview'</target>
<note />
</trans-unit>
<trans-unit id="optsOptimizationData">
<source>Specify included optimization information, the default is file. Important for distributed libraries.</source>
<target state="new">Specify included optimization information, the default is file. Important for distributed libraries.</target>
Expand All @@ -517,6 +517,11 @@
<target state="new">Disable implicit generation of constructs using reflection</target>
<note />
</trans-unit>
<trans-unit id="optsSetLangVersion">
<source>Specify language version such as 'latest' or 'preview'.</source>
<target state="new">Specify language version such as 'latest' or 'preview'.</target>
<note />
</trans-unit>
<trans-unit id="optsSignatureData">
<source>Include F# interface information, the default is file. Essential for distributing libraries.</source>
<target state="new">Include F# interface information, the default is file. Essential for distributing libraries.</target>
Expand Down
Loading