diff --git a/src/Fable.Transforms/FSharp2Fable.Util.fs b/src/Fable.Transforms/FSharp2Fable.Util.fs index e617d91c37..895dec1b7b 100644 --- a/src/Fable.Transforms/FSharp2Fable.Util.fs +++ b/src/Fable.Transforms/FSharp2Fable.Util.fs @@ -977,8 +977,11 @@ module TypeHelpers = open Patterns let genParamName (genParam: FSharpGenericParameter) = + // NOTE: This workaround seems not to be necessary with F# 7 // Sometimes the names of user-declared and compiler-generated clash, see #1900 and https://github.com/dotnet/fsharp/issues/13062 - let name = if genParam.IsCompilerGenerated then "$" + genParam.Name.Replace("?", "$") else genParam.Name + // let name = if genParam.IsCompilerGenerated then "$" + genParam.Name.Replace("?", "$") else genParam.Name + + let name = genParam.Name match Compiler.Language with // In Dart we cannot have the same generic name as a variable or argument, so we add $ to reduce the probabilities of conflict // Other solutions would be to add generic names to the name deduplication context or enforce Dart case conventions: diff --git a/tests/Dart/src/MiscTests.fs b/tests/Dart/src/MiscTests.fs index ac111c04ff..4b737fad28 100644 --- a/tests/Dart/src/MiscTests.fs +++ b/tests/Dart/src/MiscTests.fs @@ -62,7 +62,18 @@ type ElmishWidget<'Model, 'View, 'Msg>(view: 'Model -> ('Msg -> unit) -> 'View) let _view = view member _.Render(model, dispatch) = _view model dispatch +type MyRecord<'a> = + { Value: 'a } + // Check that F# is not automatically assigning 'a name to the argument's generic parameter + + static member Stringify v = string v + + let tests() = + testCase "automatically generated generic names don't conflict" <| fun () -> + MyRecord.Stringify 456 + |> equal "456" + testCase "ref works" <| fun () -> let x = ref 5 increase x