Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove workaround for fsharp/issues/13062 #3276

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 4 additions & 1 deletion src/Fable.Transforms/FSharp2Fable.Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions tests/Dart/src/MiscTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>.Stringify 456
|> equal "456"

testCase "ref works" <| fun () ->
let x = ref 5
increase x
Expand Down