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
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"fantomas": {
"version": "7.0.6",
"version": "8.0.0",
"commands": [
"fantomas"
],
Expand All @@ -17,7 +17,7 @@
"rollForward": false
},
"fsharp-analyzers": {
"version": "0.38.0",
"version": "0.39.2",
"commands": [
"fsharp-analyzers"
],
Expand Down
4 changes: 2 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>build</IncludeAssets>
</PackageReference>
<PackageReference Include="G-Research.FSharp.Analyzers" Version="0.24.0">
<PackageReference Include="G-Research.FSharp.Analyzers" Version="0.25.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Ionide.Analyzers" Version="0.18.0">
<PackageReference Include="Ionide.Analyzers" Version="0.19.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>analyzers</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion src/Fable.Analyzers/Fable.Analyzers.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FSharp.Analyzers.SDK" Version="0.38.0"/>
<PackageReference Include="FSharp.Analyzers.SDK" Version="0.39.2"/>
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/Fable.Compiler/BrowserInlineExprs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ let private extra =
(Decode.uint64 |> Decode.map unativeint)

let private decoder =
lazy (Decode.Auto.generateDecoder<(string * Fable.InlineExpr) array> (extra = extra))
lazy (Decode.Auto.generateDecoder<(string * Fable.InlineExpr) array>(extra = extra))

let fromString (json: string) : Result<(string * Fable.InlineExpr) array, string> = Decode.fromString decoder.Value json

#if !FABLE_COMPILER
let private encoder =
lazy (Encode.Auto.generateEncoder<(string * Fable.InlineExpr) array> (extra = extra))
lazy (Encode.Auto.generateEncoder<(string * Fable.InlineExpr) array>(extra = extra))

let toString (chunk: (string * Fable.InlineExpr) array) : string =
chunk |> encoder.Value |> Encode.toString 0
Expand Down
5 changes: 3 additions & 2 deletions src/Fable.Transforms/Babel/Fable2Babel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ module Annotation =
let makeStringEnumTypeAnnotation (ent: Fable.Entity) (attArgs: obj list) =
let rule =
match List.tryHead attArgs with
| Some(:? int as rule) -> enum<Core.CaseRules> (rule)
| Some(:? int as rule) -> enum<Core.CaseRules>(rule)
| _ -> Core.CaseRules.LowerFirst

ent.UnionCases
Expand Down Expand Up @@ -896,7 +896,7 @@ module Annotation =
let makeTypeScriptTaggedUnionTypeAnnotation com ctx genArgs (ent: Fable.Entity) (attArgs: obj list) =
let tag, rule =
match attArgs with
| (:? string as tag) :: (:? int as rule) :: _ -> tag, enum<Core.CaseRules> (rule)
| (:? string as tag) :: (:? int as rule) :: _ -> tag, enum<Core.CaseRules>(rule)
| (:? string as tag) :: _ -> tag, Core.CaseRules.LowerFirst
| _ -> "kind", Core.CaseRules.LowerFirst

Expand Down Expand Up @@ -2213,6 +2213,7 @@ but thanks to the optimisation done below we get
| _ -> ValueNone

// Make it easy to check if we are calling the expected function

and [<return: Struct>] (|CalledExpression|_|) (callerText: string) value =
match value with
| CallExpression(IdentifierIs callerText, UnrollerFromArray exprs, _, _) -> ValueSome exprs
Expand Down
2 changes: 1 addition & 1 deletion src/Fable.Transforms/Beam/Fable2Beam.Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ let private wrappedLiteral (bits: int, signed: bool) (value: int64) =

if not signed && truncated < 0L then
// 64-bit unsigned above Int64.MaxValue: does not fit an Erlang int64 literal
Beam.ErlExpr.Literal(Beam.ErlLiteral.BigInt(string<uint64> (uint64 truncated)))
Beam.ErlExpr.Literal(Beam.ErlLiteral.BigInt(string<uint64>(uint64 truncated)))
else
Beam.ErlExpr.Literal(Beam.ErlLiteral.Integer truncated)

Expand Down
2 changes: 1 addition & 1 deletion src/Fable.Transforms/Dart/Replacements.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1630,7 +1630,7 @@ let formattableString
|}
)

printJsTaggedTemplate str holes (fun i -> "$" + string<int> (i + offset))
printJsTaggedTemplate str holes (fun i -> "$" + string<int>(i + offset))

emitExpr r t args (callMacro + jsTaggedTemplate) |> Some
| "get_Format", Some x, _ -> Helper.LibCall(com, "String", "getFormat", t, [ x ], ?loc = r) |> Some
Expand Down
4 changes: 2 additions & 2 deletions src/Fable.Transforms/FSharp2Fable.Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ module Helpers =

let getCaseRule (att: FSharpAttribute) =
match Seq.tryHead att.ConstructorArguments with
| Some(_, (:? int as rule)) -> enum<CaseRules> (rule)
| Some(_, (:? int as rule)) -> enum<CaseRules>(rule)
| _ -> CaseRules.LowerFirst

unionCase.Attributes
Expand Down Expand Up @@ -1103,7 +1103,7 @@ module Helpers =
| Some(_, (:? string as name)), None ->
Some(TypeScriptTaggedUnion(tdef, typ.GenericArguments, name, CaseRules.LowerFirst))
| Some(_, (:? string as name)), Some(_, (:? int as rule)) ->
Some(TypeScriptTaggedUnion(tdef, typ.GenericArguments, name, enum<CaseRules> (rule)))
Some(TypeScriptTaggedUnion(tdef, typ.GenericArguments, name, enum<CaseRules>(rule)))
| _ -> failwith "Invalid TypeScriptTaggedUnion attribute"
| _ -> None
)
Expand Down
5 changes: 4 additions & 1 deletion src/Fable.Transforms/Python/Fable2Python.Transforms.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,10 @@ let transformGet (com: IPythonCompiler) ctx range typ (fableExpr: Fable.Expr) ki
let caseRef = getUnionCaseRef com ctx i.Entity ent uci
let narrow = libValue com ctx "union" "narrow"
let narrowedExpr = Expression.call (narrow, [ caseRef; baseExpr ])
let! finalExpr = getExpr com ctx range narrowedExpr (Expression.stringConstant fieldName)

let! finalExpr =
getExpr com ctx range narrowedExpr (Expression.stringConstant fieldName)

return finalExpr
}

Expand Down
4 changes: 2 additions & 2 deletions src/Fable.Transforms/Rust/AST/Rust.AST.Helpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ module Literals =

let mkCharLit (value: char) : Lit =
{
token = mkCharTokenLit ((string<char> value).escape_debug ())
token = mkCharTokenLit ((string<char> value).escape_debug())
kind = LitKind.Char(value)
span = DUMMY_SP
}
Expand Down Expand Up @@ -890,7 +890,7 @@ module Exprs =
value.StartsWith("\"", System.StringComparison.Ordinal)
&& value.EndsWith("\"", System.StringComparison.Ordinal)
then
"\"" + value[1 .. (value.Length - 2)].escape_debug () + "\""
"\"" + value[1 .. (value.Length - 2)].escape_debug() + "\""
else
value

Expand Down
2 changes: 1 addition & 1 deletion src/Fable.Transforms/Rust/AST/Rust.AST.Impl.fs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ type Expr with
type MacCall with

member self.span() : Span =
self.path.span.to_ (self.args.span().unwrap_or (self.path.span))
self.path.span.to_ (self.args.span().unwrap_or(self.path.span))

type MacArgs with

Expand Down
2 changes: 1 addition & 1 deletion src/Fable.Transforms/Rust/AST/Rust.AST.Parser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ type ExprPrecedence with
| ExprPrecedence.Range -> PREC_RANGE

// Binop-like expr kinds, handled by `AssocOp`.
| ExprPrecedence.Binary(op) -> AssocOp.from_ast_binop(op).precedence ()
| ExprPrecedence.Binary(op) -> AssocOp.from_ast_binop(op).precedence()
| ExprPrecedence.Cast -> AssocOp.As.precedence ()
| ExprPrecedence.Type -> AssocOp.Colon.precedence ()

Expand Down
14 changes: 7 additions & 7 deletions src/Fable.Transforms/Rust/AST/Rust.AST.Pretty.fs
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,11 @@ type Printer with
self.buf[self.right] <- entry
self.scan_stack.push_front (self.right)

member self.scan_pop() : usize = self.scan_stack.pop_front().unwrap ()
member self.scan_pop() : usize = self.scan_stack.pop_front().unwrap()

member self.scan_top() : usize = self.scan_stack.front().unwrap ()
member self.scan_top() : usize = self.scan_stack.front().unwrap()

member self.scan_pop_bottom() : usize = self.scan_stack.pop_back().unwrap ()
member self.scan_pop_bottom() : usize = self.scan_stack.pop_back().unwrap()

member self.advance_right() =
self.right <- self.right + 1
Expand Down Expand Up @@ -501,7 +501,7 @@ type Printer with
member self.get_top() : PrintStackElem =
self.print_stack
.last()
.unwrap_or (
.unwrap_or(
{
offset = 0
pbreak = PrintStackBreak.Broken(Breaks.Inconsistent)
Expand Down Expand Up @@ -531,7 +531,7 @@ type Printer with

member self.print_end() =
debug ("print End -> pop End")
self.print_stack.pop().unwrap () |> ignore
self.print_stack.pop().unwrap() |> ignore

member self.print_break(b: BreakToken, l: isize) =
let top = self.get_top ()
Expand Down Expand Up @@ -573,7 +573,7 @@ type Printer with

// self.out.reserve(self.pending_indentation)
// self.out.extend(std.iter.repeat(' ').take(self.pending_indentation))
self.out.push_str (" ".repeat (self.pending_indentation))
self.out.push_str (" ".repeat(self.pending_indentation))

self.pending_indentation <- 0
self.out.push_str (s)
Expand Down Expand Up @@ -637,7 +637,7 @@ type Printer with
member self.hardbreak() = self.spaces (_SIZE_INFINITY)

member self.is_beginning_of_line() : bool =
self.last_token().is_eof () || self.last_token().is_hardbreak_tok ()
self.last_token().is_eof() || self.last_token().is_hardbreak_tok()

static member hardbreak_tok_offset(off: isize) : Token =
Token.Break(
Expand Down
28 changes: 14 additions & 14 deletions src/Fable.Transforms/Rust/AST/Rust.AST.State.fs
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ let literal_to_string (lit: token.Lit) : string =
| token.LitKind.Char -> format ("'{0}'", symbol)
| token.LitKind.Str -> format ("\"{0}\"", symbol)
| token.LitKind.StrRaw(n) ->
let delim = "#".repeat (n |> usize)
let delim = "#".repeat(n |> usize)
format ("r{0}\"{1}\"{2}", delim, symbol, delim)
| token.LitKind.ByteStr -> format ("b\"{0}\"", symbol)
| token.LitKind.ByteStrRaw(n) ->
let delim = "#".repeat (n |> usize)
let delim = "#".repeat(n |> usize)
format ("br{0}\"{1}\"{2}", delim, symbol, delim)
| token.LitKind.Integer
| token.LitKind.Float
Expand All @@ -238,7 +238,7 @@ let literal_to_string (lit: token.Lit) : string =
// out.push_str(suffix.as_str())

let visibility_qualified (vis: ast.Visibility, s: string) : string =
let vis_str = State.new_().to_string (fun (s) -> s.print_visibility (vis))
let vis_str = State.new_().to_string(fun (s) -> s.print_visibility (vis))
format ("{0}{1}", vis_str, s)

// interface std.ops.Deref with // for State
Expand Down Expand Up @@ -440,7 +440,7 @@ type State with
| Some(cmnts) -> cmnts.current <- cmnts.current + 1

member self.next_comment() : Option<Comment> =
self.comments().and_then (fun (c) -> c.next ())
self.comments().and_then(fun (c) -> c.next ())

member self.print_literal(lit: ast.Lit) =
self.maybe_print_comment (lit.span.lo ())
Expand All @@ -451,7 +451,7 @@ type State with
match style with
| ast.StrStyle.Cooked -> format ("\"{0}\"", st.escape_debug ())
| ast.StrStyle.Raw(n) ->
let delim = "#".repeat (n |> usize)
let delim = "#".repeat(n |> usize)
format ("r{0}\"{1}\"{2}", delim, st, delim)

self.s.word (st)
Expand Down Expand Up @@ -701,7 +701,7 @@ type State with
member self.break_offset_if_not_bol(n: usize, off: isize) =
if not (self.s.is_beginning_of_line ()) then
self.s.break_offset (n, off)
elif off <> 0 && self.s.last_token().is_hardbreak_tok () then
elif off <> 0 && self.s.last_token().is_hardbreak_tok() then
// We do something pretty sketchy here: tuck the nonzero
// offset-adjustment we were going to deposit along with the
// break into the previous hardbreak.
Expand All @@ -717,7 +717,7 @@ type State with
| token.Nonterminal.NtBlock(e) -> self.block_to_string (e)
| token.Nonterminal.NtStmt(e) -> self.stmt_to_string (e)
| token.Nonterminal.NtPat(e) -> self.pat_to_string (e)
| token.Nonterminal.NtIdent(e, is_raw) -> IdentPrinter.for_ast_ident(e, is_raw).to_string ()
| token.Nonterminal.NtIdent(e, is_raw) -> IdentPrinter.for_ast_ident(e, is_raw).to_string()
| token.Nonterminal.NtLifetime(e) -> e.to_string ()
| token.Nonterminal.NtLiteral(e) -> self.expr_to_string (e)
| token.Nonterminal.NtTT(tree) -> self.tt_to_string (tree)
Expand Down Expand Up @@ -774,7 +774,7 @@ type State with
| token.TokenKind.Literal(lit) -> literal_to_string (lit)

// Name components
| token.TokenKind.Ident(s, is_raw) -> IdentPrinter.new_(s, is_raw, convert_dollar_crate).to_string ()
| token.TokenKind.Ident(s, is_raw) -> IdentPrinter.new_(s, is_raw, convert_dollar_crate).to_string()
| token.TokenKind.Lifetime(s) -> s.to_string ()

// Other
Expand Down Expand Up @@ -858,7 +858,7 @@ type State with
member self.comments() : Option<Comments> = self.comments_

member self.print_ident(ident: Ident) =
self.s.word (IdentPrinter.for_ast_ident(ident, ident.is_raw_guess ()).to_string ())
self.s.word (IdentPrinter.for_ast_ident(ident, ident.is_raw_guess ()).to_string())

self.ann.post (self, AnnNode.Ident(ident))

Expand Down Expand Up @@ -912,14 +912,14 @@ type State with
let mutable i = 0

for elt in elts do
self.maybe_print_comment (get_span(elt).hi ())
self.maybe_print_comment (get_span(elt).hi())
op (self, elt)
i <- i + 1

if i < len then
self.s.word (",")

self.maybe_print_trailing_comment (get_span (elt), Some(get_span(elts[i]).hi ()))
self.maybe_print_trailing_comment (get_span (elt), Some(get_span(elts[i]).hi()))

self.s.space_if_not_bol ()

Expand Down Expand Up @@ -1593,7 +1593,7 @@ type State with
self.print_expr_cond_paren (
scrutinee,
self.cond_needs_par (scrutinee)
|| parser.needs_par_as_let_scrutinee (scrutinee.precedence().order ())
|| parser.needs_par_as_let_scrutinee (scrutinee.precedence().order())
)

member self.print_else(els: Option<ast.Expr>) =
Expand Down Expand Up @@ -1645,7 +1645,7 @@ type State with
self.s.pclose ()

member self.print_expr_maybe_paren(expr: ast.Expr, prec: i8) =
self.print_expr_cond_paren (expr, expr.precedence().order () < prec)
self.print_expr_cond_paren (expr, expr.precedence().order() < prec)

/// Prints an expr using syntax that's acceptable in a condition position, such as the `cond` in
/// `if cond then ... }`.
Expand Down Expand Up @@ -2766,7 +2766,7 @@ type State with
member self.print_remaining_comments() =
// If there aren't any remaining comments, then we need to manually
// make sure there is a line break at the end_.
if self.next_comment().is_none () then
if self.next_comment().is_none() then
self.s.hardbreak ()

let mutable cmnt = self.next_comment ()
Expand Down
4 changes: 2 additions & 2 deletions src/Fable.Transforms/Rust/AST/Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ module Helpers =
let fun_to_string (decl: FnDecl, header: FnHeader, name: Ident, generics: Generics) : string =
State
.new_()
.to_string (fun (s) ->
.to_string(fun (s) ->
s.head ("")
s.print_fn (decl, header, Some(name), generics)
s.s.end_ () // Close the head box.
s.s.end_ () // Close the outer box.
)

let variant_to_string (var: Variant) : string =
State.new_().to_string (fun (s) -> s.print_variant (var))
State.new_().to_string(fun (s) -> s.print_variant (var))

[<Fact>]
let test_fun_to_string () =
Expand Down
6 changes: 3 additions & 3 deletions src/Fable.Transforms/Rust/Fable2Rust.fs
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ module TypeInfo =
| [ Fable.Unit ] -> []
| _ -> argTypes

let argCount = string<int> (List.length argTypes)
let argCount = string<int>(List.length argTypes)
let genArgs = argTypes @ [ returnType ]
transformImportType com ctx genArgs "Native" ("Func" + argCount)

Expand Down Expand Up @@ -1047,7 +1047,7 @@ module TypeInfo =
transformGenericType com ctx genArgs (rawIdent "Result")

let transformChoiceType com ctx genArgs : Rust.Ty =
let argCount = string<int> (List.length genArgs)
let argCount = string<int>(List.length genArgs)
transformImportType com ctx genArgs "Choice" ("Choice`" + argCount)

let transformRefCellType com ctx genArg : Rust.Ty =
Expand Down Expand Up @@ -1802,7 +1802,7 @@ module Util =
| [ Fable.Unit ] -> []
| _ -> argTypes

let argCount = string<int> (List.length argTypes)
let argCount = string<int>(List.length argTypes)
let funcWrap = getLibraryImportName com ctx "Native" ("Func" + argCount)
let expr = transformIdent com ctx None ident

Expand Down
2 changes: 1 addition & 1 deletion src/fable-compiler-js/src/app.fs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ type SourceWriter(sourcePath, targetPath, projDir, options: CmdLineOptions, file

member _.Dispose() = ()

member _.SourceMap = mapGenerator.Force().toJSON ()
member _.SourceMap = mapGenerator.Force().toJSON()
member _.Result = sb.ToString()

let printErrors showWarnings (errors: Fable.Standalone.Error[]) =
Expand Down
Loading
Loading