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

Commit62bd20c

Browse files
dsymeKevinRansom
authored andcommitted
fix compiler crash (#3275)
1 parent2fd94e0 commit62bd20c

File tree

5 files changed

+36
-6
lines changed

5 files changed

+36
-6
lines changed

‎src/fsharp/TypeChecker.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,7 @@ let AdjustAndForgetUsesOfRecValue cenv (vrefTgt: ValRef) (valScheme : ValScheme)
15761576
// Keep any values for explicit type arguments
15771577
let fixedUpExpr =
15781578
let vrefFlags,tyargs0 =
1579-
match!fixupPoint with
1579+
match fixupPoint.Value with
15801580
| Expr.App(Expr.Val (_,vrefFlags,_),_,tyargs0,[],_) -> vrefFlags,tyargs0
15811581
| Expr.Val(_,vrefFlags,_) -> vrefFlags,[]
15821582
| _ ->
@@ -1585,7 +1585,7 @@ let AdjustAndForgetUsesOfRecValue cenv (vrefTgt: ValRef) (valScheme : ValScheme)
15851585

15861586
let ityargs = generalizeTypars (List.drop (List.length tyargs0) generalizedTypars)
15871587
primMkApp (Expr.Val (vrefTgt,vrefFlags,m),fty) (tyargs0 @ ityargs) [] m
1588-
fixupPoint := fixedUpExpr)
1588+
fixupPoint.Value <- fixedUpExpr)
15891589

15901590
vrefTgt.Deref.SetValRec ValNotInRecScope
15911591
cenv.recUses <- cenv.recUses.Remove vrefTgt.Deref

‎src/fsharp/infos.fs‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,19 @@ let private CombineMethInsts ttps mtps tinst minst = (mkTyparInst ttps tinst @ m
461461

462462
/// Work out the instantiation relevant to interpret the backing metadata for a member.
463463
///
464-
/// The 'minst' is the instantiation of any generic method type parameters (this instantiation is
465-
/// not included in the MethInfo objects, but carried separately).
466-
letprivateGetInstantiationForMemberVal g isCSharpExt(typ,vref,minst)=
464+
/// The 'methTyArgs' is the instantiation of any generic method type parameters (this instantiation is
465+
/// not included in the MethInfo objects, but carried separately).
466+
letprivateGetInstantiationForMemberVal g isCSharpExt(typ,vref,methTyArgs:TypeInst)=
467467
letmemberParentTypars,memberMethodTypars,_retTy,parentTyArgs= AnalyzeTypeOfMemberVal isCSharpExt g(typ,vref)
468-
CombineMethInsts memberParentTypars memberMethodTypars parentTyArgs minst
468+
/// In some recursive inference cases involving constraints this may need to be
469+
/// fixed up - we allow uniform generic recursion but nothing else.
470+
/// See https://github.com/Microsoft/visualfsharp/issues/3038#issuecomment-309429410
471+
letmethTyArgsFixedUp=
472+
if methTyArgs.Length< memberMethodTypars.Lengththen
473+
methTyArgs@(List.skip methTyArgs.Length memberMethodTypars|> generalizeTypars)
474+
else
475+
methTyArgs
476+
CombineMethInsts memberParentTypars memberMethodTypars parentTyArgs methTyArgsFixedUp
469477

470478
/// Work out the instantiation relevant to interpret the backing metadata for a property.
471479
letprivateGetInstantiationForPropertyVal g(typ,vref)=

‎tests/fsharp/tests.fs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,6 +2126,9 @@ module TypecheckTests =
21262126
[<Test>]
21272127
let``type check neg97``()= singleNegTest(testConfig"typecheck/sigs")"neg97"
21282128

2129+
[<Test>]
2130+
let``type check neg98``()= singleNegTest(testConfig"typecheck/sigs")"neg98"
2131+
21292132
[<Test>]
21302133
let``type check neg_byref_1``()= singleNegTest(testConfig"typecheck/sigs")"neg_byref_1"
21312134

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
neg98.fs(10,20,10,34): typecheck error FS0768: The member 'Eval' doesnot accept the correct number of arguments.2 argument(s) are expected, but2 were given. The required signature is 'member Evaluator.Eval : ('t-> 'u)-> 'u list-> 'ret'.
3+
4+
neg98.fs(10,23,10,27): typecheck error FS0017: The member 'Eval : 'a* 'b-> 'c' doesnot have the correct typeto override the corresponding abstract method. The required signature is 'Eval<'u> : ('t-> 'u)-> 'u list-> 'a'.
5+
6+
neg98.fs(10,23,10,27): typecheck error FS0367: The member 'Eval : 'a* 'b-> 'c' doesnot have the correct number of arguments. The required signature is 'Eval<'u> : ('t-> 'u)-> 'u list-> 'a'.
7+
8+
neg98.fs(9,22,9,36): typecheck error FS0783: At least one override didnot correctly implement its corresponding abstract member
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
moduleTest
3+
4+
typeEvaluator<'t,'ret>=abstractmemberEval :('t->'u)->'ulist->'ret
5+
and 't Crate=abstractmemberEval :Evaluator<'t,'ret>->'ret
6+
7+
moduleBar=
8+
letfoo(x:'t Crate)=
9+
x.Eval{new Evaluator<_,_>with
10+
member__.Eval(x,y)= failwith""
11+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp