Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0c88694

Browse files
dsymeKevinRansom
authored andcommitted
fix generalization of top-level value that uses a mutable top-level binding (#3389)
1 parent938da3e commit0c88694

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

‎src/fsharp/TypeChecker.fs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,9 +2120,11 @@ module GeneralizationHelpers =
21202120
&& List.forall (IsGeneralizableValue g) args
21212121

21222122
| Expr.LetRec(binds,body,_,_) ->
2123+
binds |> List.forall (fun b -> not b.Var.IsMutable) &&
21232124
binds |> List.forall (fun b -> IsGeneralizableValue g b.Expr) &&
21242125
IsGeneralizableValue g body
21252126
| Expr.Let(bind,body,_,_) ->
2127+
not bind.Var.IsMutable &&
21262128
IsGeneralizableValue g bind.Expr &&
21272129
IsGeneralizableValue g body
21282130

‎tests/fsharp/core/letrec/test.fsx‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,23 @@ module BasicPermutations =
625625
// to the base implementations of overridden members <file> <line>
626626
overridex.Foo a=base.Foo(a)
627627

628+
moduleTest2=
629+
lettag=
630+
let mutablei=0
631+
fun _-> i<- i+1; i// this should _not_ generalize, see https://github.com/Microsoft/visualfsharp/issues/3358
632+
633+
test"vwekjwve91"(tag())1
634+
test"vwekjwve92"(tag())2
635+
test"vwekjwve93"(tag())3
636+
637+
moduleTest3=
638+
let rectag=
639+
let mutablei=0
640+
fun _-> i<- i+1; i// this should _not_ generalize, see https://github.com/Microsoft/visualfsharp/issues/3358
641+
642+
test"vwekjwve94"(tag())1
643+
test"vwekjwve95"(tag())2
644+
test"vwekjwve96"(tag())3
628645

629646
#if TESTS_AS_APP
630647
letRUN()=!failures

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp