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
10 changes: 5 additions & 5 deletions src/Fable.Compiler/ProjectCracker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ let getFableLibraryPath (opts: CrackerOptions) (shouldCopy: bool) =
|}
|> Option.defaultWith (fun () ->
Fable.FableError
$"Cannot find [temp/]{buildDir} from {baseDir}.\nPlease, make sure you build {buildDir}"
$"Cannot find [temp/]%s{buildDir} from %s{baseDir}.\nPlease, make sure you build %s{buildDir}"
|> raise
)

Expand Down Expand Up @@ -786,7 +786,7 @@ let loadPrecompiledInfo (opts: CrackerOptions) otherOptions sourceFiles =
// Check if precompiled compiler version and options match
if info.CompilerVersion <> Literals.VERSION then
Fable.FableError(
$"Library was precompiled using Fable v{info.CompilerVersion} but you're using v{Literals.VERSION}. Please use same version."
$"Library was precompiled using Fable v%s{info.CompilerVersion} but you're using v%s{Literals.VERSION}. Please use same version."
)
|> raise

Expand Down Expand Up @@ -816,7 +816,7 @@ let loadPrecompiledInfo (opts: CrackerOptions) otherOptions sourceFiles =
|> List.map (fun f -> " " + File.relPathToCurDir f)
|> String.concat Log.newLine
// TODO: This should likely be an error but make it a warning for now
Log.warning ($"Detected outdated files in precompiled lib:{Log.newLine}{outdated}")
Log.warning ($"Detected outdated files in precompiled lib:%s{Log.newLine}%s{outdated}")
with er ->
Log.warning ("Cannot check timestamp of precompiled files: " + er.Message)

Expand Down Expand Up @@ -849,7 +849,7 @@ let getFullProjectOpts (resolver: ProjectCrackerResolver) (opts: CrackerOptions)
if not isOlder then
Log.verbose (
lazy
$"Cached project info ({cacheTimestamp}) will be discarded because {File.relPathToCurDir filePath} ({fileTimestamp}) is newer"
$"Cached project info (%O{cacheTimestamp}) will be discarded because %s{File.relPathToCurDir filePath} (%O{fileTimestamp}) is newer"
)

isOlder
Expand Down Expand Up @@ -911,7 +911,7 @@ let getFullProjectOpts (resolver: ProjectCrackerResolver) (opts: CrackerOptions)
else
"Debug"

$"Won't reuse compiled files because last compilation was for {otherMode} mode"
$"Won't reuse compiled files because last compilation was for %s{otherMode} mode"
)

isMostRecent
Expand Down
16 changes: 8 additions & 8 deletions src/Fable.Compiler/Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,16 @@ module File =
let creationTime = File.GetCreationTime(lockFile)

if (DateTime.Now - creationTime).TotalMilliseconds > float timeoutMs then
Log.always $"Found old lock file {relPathToCurDir lockFile} ({creationTime})"
Log.always $"Found old lock file %s{relPathToCurDir lockFile} (%O{creationTime})"

try
File.Delete(lockFile)
with _ ->
()
else
Log.always $"Directory is locked, waiting for max {timeoutMs / 1000}s"
Log.always $"Directory is locked, waiting for max %d{timeoutMs / 1000}s"

Log.always $"If compiler gets stuck, delete {relPathToCurDir lockFile}"
Log.always $"If compiler gets stuck, delete %s{relPathToCurDir lockFile}"
elif waitedMs >= timeoutMs then
Fable.AST.Fable.FableError "LockTimeOut" |> raise

Expand All @@ -348,7 +348,7 @@ module File =
if fileCreated then
File.Delete(lockFile)
with e ->
Log.always $"Could not delete lock file: {lockFile} ({e.Message})"
Log.always $"Could not delete lock file: %s{lockFile} (%s{e.Message})"

[<RequireQualifiedAccess>]
module Process =
Expand Down Expand Up @@ -388,7 +388,7 @@ module Process =
let findInPath (exec: string) =
match tryFindInPath exec with
| Some exec -> exec
| None -> failwith $"Cannot find {exec} in PATH"
| None -> failwith $"Cannot find %s{exec} in PATH"

let getCurrentAssembly () = typeof<TypeInThisAssembly>.Assembly

Expand All @@ -413,7 +413,7 @@ module Process =
// TODO: We should use cliArgs.RootDir instead of Directory.GetCurrentDirectory here but it's only informative
// so let's leave it as is for now to avoid having to pass the cliArgs through all the call sites
if not redirectOutput then
Log.always $"""{File.relPathToCurDir workingDir}> {exePath} {String.concat " " args}"""
Log.always $"""%s{File.relPathToCurDir workingDir}> %s{exePath} %s{String.concat " " args}"""

let psi = ProcessStartInfo(exePath)

Expand Down Expand Up @@ -616,7 +616,7 @@ module Imports =
let importPath = Path.Combine(projDir, importPath)
let targetDir = Path.GetDirectoryName(targetPath)
getRelativePath targetDir importPath
| Some macro, _ -> failwith $"Unknown import macro: {macro}"
| Some macro, _ -> failwith $"Unknown import macro: %s{macro}"
| None, None ->
if isAbsolutePath importPath then
let sourceDir = Path.GetDirectoryName(sourcePath)
Expand Down Expand Up @@ -934,7 +934,7 @@ type PrecompiledInfoImpl(fableModulesDir: string, info: PrecompiledInfoJson) =
IO.Path.Combine(fableModulesDir, "precompiled_info.json")

static member GetInlineExprsPath(fableModulesDir, index: int) =
IO.Path.Combine(fableModulesDir, "inline_exprs", $"inline_exprs_{index}.json")
IO.Path.Combine(fableModulesDir, "inline_exprs", $"inline_exprs_%d{index}.json")

static member Load(fableModulesDir: string) =
try
Expand Down
2 changes: 1 addition & 1 deletion src/Fable.Transforms/BabelPrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ module PrinterExtensions =
|> List.iter (
function
| _, NullOrUndefinedOrVoid -> ()
| key, StringConstant value -> printProp (fun () -> printer.Print($"{key}=\"{value}\""))
| key, StringConstant value -> printProp (fun () -> printer.Print($"%s{key}=\"%s{value}\""))
| key, value ->
printProp (fun () ->
printer.Print(key + "={")
Expand Down
12 changes: 6 additions & 6 deletions src/Fable.Transforms/Dart/Fable2Dart.fs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ module Util =
match transformAndCaptureExpr com ctx entRef with
| [], IdentExpression ident -> Some ident
| _ ->
addError com [] None $"Unexpected, entity ref for {ent.FullName} is not an identifier"
addError com [] None $"Unexpected, entity ref for %s{ent.FullName} is not an identifier"

None
)
Expand Down Expand Up @@ -1956,17 +1956,17 @@ module Util =
match transformCallArgs com ctx (CallInfo info) with
| [], args -> args
| _, args ->
$"Rewrite base arguments for {classDecl.Entity.FullName} so they can be compiled as Dart expressions"
$"Rewrite base arguments for %s{classDecl.Entity.FullName} so they can be compiled as Dart expressions"
|> addWarning com [] e.Range

args
| Some(Fable.Value _ as e) ->
$"Ignoring base call for {classDecl.Entity.FullName}"
$"Ignoring base call for %s{classDecl.Entity.FullName}"
|> addWarning com [] e.Range

[]
| Some e ->
$"Unexpected base call for {classDecl.Entity.FullName}"
$"Unexpected base call for %s{classDecl.Entity.FullName}"
|> addError com [] e.Range

[]
Expand Down Expand Up @@ -2316,7 +2316,7 @@ module Util =
let name =
match p.Name with
| Some name -> name
| None -> $"arg{i}$"
| None -> $"arg%d{i}$"

let t = transformType com ctx p.Type
FunctionArg(makeImmutableIdent t name) // TODO, isOptional=p.IsOptional, isNamed=p.IsNamed)
Expand Down Expand Up @@ -2391,7 +2391,7 @@ module Util =
=
match implementsIterable, baseType with
| Some iterable, Some _ ->
$"Types implementing IEnumerable cannot inherit from another class: {classEnt.FullName}"
$"Types implementing IEnumerable cannot inherit from another class: %s{classEnt.FullName}"
|> addError com [] None

Some iterable
Expand Down
10 changes: 5 additions & 5 deletions src/Fable.Transforms/Dart/Replacements.fs
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ let tryEntityIdent (com: Compiler) entFullName =
| BuiltinDefinition(FSharpReference _) -> makeImportLib com MetaType "FSharpRef" "Types" |> Some
| BuiltinDefinition(FSharpResult _) -> makeImportLib com MetaType "FSharpResult$2" "Result" |> Some
| BuiltinDefinition(FSharpChoice genArgs) ->
let membName = $"FSharpChoice${List.length genArgs}"
let membName = $"FSharpChoice$%d{List.length genArgs}"
makeImportLib com MetaType membName "Choice" |> Some
// | BuiltinDefinition BclGuid -> jsTypeof "string" expr
| BuiltinDefinition(BclHashSet _)
Expand Down Expand Up @@ -1387,7 +1387,7 @@ let strings (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg: Expr opt
| "GetEnumerator", Some c, _ -> stringToCharSeq c |> getEnumerator com r t |> Some
| ("Contains" | "StartsWith" | "EndsWith" as meth), Some c, arg :: _ ->
if List.isMultiple args then
addWarning com ctx.InlinePath r $"String.{meth}: second argument is ignored"
addWarning com ctx.InlinePath r $"String.%s{meth}: second argument is ignored"

Helper.InstanceCall(c, Naming.lowerFirst meth, t, [ arg ], ?loc = r) |> Some
| ReplaceName [ "ToUpper", "toUpperCase"
Expand Down Expand Up @@ -3158,7 +3158,7 @@ let random (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg: Expr opti
| meth, Some thisArg ->
let meth =
if meth = "Next" then
$"Next{List.length args}"
$"Next%d{List.length args}"
else
meth

Expand Down Expand Up @@ -3273,7 +3273,7 @@ let regex com (ctx: Context) r t (i: CallInfo) (thisArg: Expr option) (args: Exp
match thisArg, args with
| Some thisArg, args ->
if args.Length > 2 then
$"Regex.{meth} doesn't support more than 2 arguments"
$"Regex.%s{meth} doesn't support more than 2 arguments"
|> addError com ctx.InlinePath r

thisArg :: args |> Some
Expand Down Expand Up @@ -4194,6 +4194,6 @@ let tryType typ =
| FSharpMap(key, value) -> Some(Types.fsharpMap, maps, [ key; value ])
| FSharpSet genArg -> Some(Types.fsharpSet, sets, [ genArg ])
| FSharpResult(genArg1, genArg2) -> Some(Types.result, results, [ genArg1; genArg2 ])
| FSharpChoice genArgs -> Some($"{Types.choiceNonGeneric}`{List.length genArgs}", results, genArgs)
| FSharpChoice genArgs -> Some($"%s{Types.choiceNonGeneric}`%d{List.length genArgs}", results, genArgs)
| FSharpReference genArg -> Some(Types.refCell, refCells, [ genArg ])
| _ -> None
13 changes: 8 additions & 5 deletions src/Fable.Transforms/FSharp2Fable.Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2580,16 +2580,19 @@ module Util =
let failReplace (com: IFableCompiler) ctx r (info: Fable.ReplaceCallInfo) (thisArg: Fable.Expr option) =
let msg =
if info.DeclaringEntityFullName.StartsWith("Fable.Core.", StringComparison.Ordinal) then
$"{info.DeclaringEntityFullName}.{info.CompiledName} is not supported, try updating fable tool"
$"%s{info.DeclaringEntityFullName}.%s{info.CompiledName} is not supported, try updating fable tool"
else
com.WarnOnlyOnce(
"Fable only supports a subset of standard .NET API, please check https://fable.io/docs/dotnet/compatibility.html. For external libraries, check whether they are Fable-compatible in the package docs."
)

$"""{info.DeclaringEntityFullName}.{info.CompiledName}{if Option.isSome thisArg then
""
else
" (static)"} is not supported by Fable"""
let staticSuffix =
if Option.isSome thisArg then
""
else
" (static)"

$"%s{info.DeclaringEntityFullName}.%s{info.CompiledName}%s{staticSuffix} is not supported by Fable"

msg |> addErrorAndReturnNull com ctx.InlinePath r

Expand Down
8 changes: 4 additions & 4 deletions src/Fable.Transforms/FSharp2Fable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ let private transformNewUnion com ctx r fsType (unionCase: FSharpUnionCase) (arg
match argExprs with
| [] -> transformStringEnum rule unionCase
| _ ->
$"StringEnum types cannot have fields: {tdef.TryFullName}"
$"StringEnum types cannot have fields: %O{tdef.TryFullName}"
|> addErrorAndReturnNull com ctx.InlinePath r

| OptionUnion(typ, isStruct) ->
Expand Down Expand Up @@ -723,7 +723,7 @@ let private transformExpr (com: IFableCompiler) (ctx: Context) appliedGenArgs fs
let! limit = transformExpr com ctx [] limit
let! body = transformExpr com newContext [] body
return makeForLoop r isUp ident start limit body
| _ -> return failwithf $"Unexpected loop {r}: %A{fsExpr}"
| _ -> return failwithf $"Unexpected loop %O{r}: %A{fsExpr}"

| FSharpExprPatterns.WhileLoop(guardExpr, bodyExpr, _) ->
let! guardExpr = transformExpr com ctx [] guardExpr
Expand Down Expand Up @@ -1686,7 +1686,7 @@ let private applyJsPyDecorators
let parameters =
memb.CurriedParameterGroups
|> Seq.collect id
|> Seq.mapi (fun i p -> defaultArg p.Name $"arg{i}", makeType Map.empty p.Type)
|> Seq.mapi (fun i p -> defaultArg p.Name $"arg%d{i}", makeType Map.empty p.Type)
|> Seq.toList

Replacements.Api.makeMethodInfo com None name parameters returnType
Expand Down Expand Up @@ -2760,7 +2760,7 @@ type FableCompiler(com: Compiler) =
|> List.filter (fun (i, v) ->
if ctx.CapturedBindings.Contains(i.Name) && canHaveSideEffects com v then
if isIdentUsed i.Name resolved then
$"Inlined argument {i.Name} is being captured but is also used somewhere else. "
$"Inlined argument %s{i.Name} is being captured but is also used somewhere else. "
+ "There's a risk of double evaluation."
|> addWarning com [] i.Range

Expand Down
15 changes: 8 additions & 7 deletions src/Fable.Transforms/Fable2Babel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -754,10 +754,10 @@ module Annotation =
| Replacements.Util.FSharpMap(key, value) ->
makeFableLibImportTypeAnnotation com ctx [ key; value ] "Map" "FSharpMap"
| Replacements.Util.FSharpResult(ok, err) ->
$"FSharpResult$2{Util.UnionHelpers.UNION_SUFFIX}"
$"FSharpResult$2%s{Util.UnionHelpers.UNION_SUFFIX}"
|> makeFableLibImportTypeAnnotation com ctx [ ok; err ] "Result"
| Replacements.Util.FSharpChoice genArgs ->
$"FSharpChoice${List.length genArgs}{Util.UnionHelpers.UNION_SUFFIX}"
$"FSharpChoice$%d{List.length genArgs}%s{Util.UnionHelpers.UNION_SUFFIX}"
|> makeFableLibImportTypeAnnotation com ctx genArgs "Choice"
| Replacements.Util.FSharpReference genArg ->
if isInRefOrAnyType com typ then
Expand All @@ -772,7 +772,7 @@ module Annotation =
| _ -> argTypes
|> List.mapi (fun i argType ->
FunctionTypeParam.functionTypeParam (
Identifier.identifier ($"arg{i}"),
Identifier.identifier ($"arg%d{i}"),
makeTypeAnnotation com ctx argType
)
)
Expand Down Expand Up @@ -1034,7 +1034,7 @@ module Util =
if selector.StartsWith("*", StringComparison.Ordinal) then
selector
else
$"default as {selector}"
$"default as %s{selector}"

com.GetImportExpr(ctx, selector, path, r, noMangle = true) |> ignore

Expand Down Expand Up @@ -1631,7 +1631,7 @@ module Util =
Expression.callExpression (helperRef, values, typeArguments = typeParams)
| None -> callConstructor (Some case)
| None ->
$"Unmatched union case tag: {tag} for {ent.FullName}" |> addWarning com [] r
$"Unmatched union case tag: %d{tag} for %s{ent.FullName}" |> addWarning com [] r

callConstructor None
else
Expand Down Expand Up @@ -2676,7 +2676,8 @@ but thanks to the optimisation done below we get
match List.tryItem tag ent.UnionCases with
| Some case -> Some case.Name
| None ->
$"Unmatched union case tag: {tag} for {ent.FullName}" |> addWarning com [] range
$"Unmatched union case tag: %d{tag} for %s{ent.FullName}"
|> addWarning com [] range

None
| _ -> None
Expand Down Expand Up @@ -4742,7 +4743,7 @@ but thanks to the optimisation done below we get
let noConflict = ctx.UsedNames.RootScope.Add(alias)

if not noConflict then
com.WarnOnlyOnce($"Import {alias} conflicts with existing identifier in root scope")
com.WarnOnlyOnce($"Import %s{alias} conflicts with existing identifier in root scope")

alias
else
Expand Down
2 changes: 1 addition & 1 deletion src/Fable.Transforms/FableTransforms.fs
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ module private Transforms =
match expr with
| IdentExpr _ -> None, expr
| arg ->
let ident = makeTypedIdent argType $"anonRec{com.IncrementCounter()}"
let ident = makeTypedIdent argType $"anonRec%d{com.IncrementCounter()}"

Some(ident, arg), IdentExpr ident

Expand Down
2 changes: 1 addition & 1 deletion src/Fable.Transforms/OverloadSuffix.fs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ let rec private getTypeFastFullName (genParams: IDictionary<_, _>) (t: Fable.Typ
let typeName = getTypeFastFullName genParams genArg

if isStruct then
$"System.Nullable<{typeName}>"
$"System.Nullable<%s{typeName}>"
else
// there is no overload distinction for nullable reference types,
// so the name and overload suffix are the same as the inner type
Expand Down
Loading
Loading