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

Commit1414fe5

Browse files
dsymeKevinRansom
authored andcommitted
better fix for #5369 (#5398)
1 parentd636c94 commit1414fe5

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

‎src/fsharp/TastPickle.fs‎

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ type WriterState =
121121
onlerefs:Table<int* int[]>
122122
osimpletys:Table<int>
123123
oglobals:TcGlobals
124-
mutable isStructThisArgPos:bool
125124
ofile:string
126125
/// Indicates if we are using in-memory format, where we store XML docs as well
127126
oInMem:bool
@@ -506,9 +505,13 @@ let p_maybe_lazy p (x: MaybeLazy<_>) st =
506505
p_lazy_impl p x.Value st
507506

508507
letp_hole()=
509-
leth= ref(None: 'Tpickler option)
508+
leth= ref(None:('T-> WriterState-> unit) option)
510509
(fun f-> h:= Some f),(fun x st->match!hwith Some f-> f x st| None-> pfailwith st"p_hole: unfilled hole")
511510

511+
letp_hole2()=
512+
leth= ref(None:('Arg-> 'T-> WriterState-> unit) option)
513+
(fun f-> h:= Some f),(fun arg x st->match!hwith Some f-> f arg x st| None-> pfailwith st"p_hole2: unfilled hole")
514+
512515
letu_array_core f n st=
513516
letres= Array.zeroCreate n
514517
for i=0to n-1do
@@ -710,8 +713,7 @@ let pickleObjWithDanglingCcus inMem file g scope p x =
710713
osimpletys=Table<_>.Create"osimpletys"
711714
oglobals=g
712715
ofile=file
713-
oInMem=inMem
714-
isStructThisArgPos=false}
716+
oInMem=inMem}
715717
p x st1
716718
letsizes=
717719
st1.otycons.Size,
@@ -733,8 +735,7 @@ let pickleObjWithDanglingCcus inMem file g scope p x =
733735
osimpletys=Table<_>.Create"osimpletys (fake)"
734736
oglobals=g
735737
ofile=file
736-
oInMem=inMem
737-
isStructThisArgPos=false}
738+
oInMem=inMem}
738739
p_tup7
739740
(p_array p_encoded_ccuref)
740741
(p_tup3 p_int p_int p_int)
@@ -1266,7 +1267,9 @@ let u_rfref st = let a,b = u_tup2 u_tcref u_string st in RFRef(a,b)
12661267
letu_tpref st= u_local_item_ref st.itypars st
12671268

12681269
// forward reference
1269-
letfill_p_ty,p_ty= p_hole()
1270+
letfill_p_ty2,p_ty2= p_hole2()
1271+
1272+
letp_ty= p_ty2false
12701273
letp_tys=(p_list p_ty)
12711274

12721275
letfill_p_attribs,p_attribs= p_hole()
@@ -1291,9 +1294,7 @@ let p_nonlocal_val_ref (nlv:NonLocalValOrMemberRef) st =
12911294
match key.TypeForLinkagewith
12921295
| None->false
12931296
| Some ty-> checkForInRefStructThisArg st ty
1294-
st.isStructThisArgPos<- isStructThisArgPos
1295-
p_option p_ty key.TypeForLinkage st
1296-
st.isStructThisArgPos<-false
1297+
p_option(p_ty2 isStructThisArgPos) key.TypeForLinkage st
12971298

12981299
let recp_vref ctxt x st=
12991300
match xwith
@@ -1553,9 +1554,17 @@ let u_tyar_spec st =
15531554

15541555
letu_tyar_specs=(u_list u_tyar_spec)
15551556

1556-
let_=fill_p_ty(fun ty st->
1557+
let_=fill_p_ty2(fun isStructThisArgPos ty st->
15571558
letty= stripTyparEqns ty
1558-
letty=if isInByrefTy st.oglobals ty&& st.isStructThisArgPosthen destByrefTy st.oglobals tyelse ty
1559+
1560+
// See comment on 'checkForInRefStructThisArg'
1561+
letty=
1562+
if isInByrefTy st.oglobals ty&& isStructThisArgPosthen
1563+
// Convert the inref to a byref
1564+
mkByrefTy st.oglobals(destByrefTy st.oglobals ty)
1565+
else
1566+
ty
1567+
15591568
match tywith
15601569
| TType_tuple(tupInfo,l)->
15611570
if evalTupInfoIsStruct tupInfothen
@@ -1566,11 +1575,15 @@ let _ = fill_p_ty (fun ty st ->
15661575
| TType_app(tc,tinst)-> p_byte2 st; p_tup2(p_tcref"typ") p_tys(tc,tinst) st
15671576
| TType_fun(d,r)->
15681577
p_byte3 st
1569-
p_ty d st
1570-
st.isStructThisArgPos<-false
1578+
// Note, the "this" argument may be found in the domain position of a function type, so propagate the isStructThisArgPos value
1579+
p_ty2isStructThisArgPosd st
15711580
p_ty r st
15721581
| TType_var r-> p_byte4 st; p_tpref r st
1573-
| TType_forall(tps,r)-> p_byte5 st; p_tup2 p_tyar_specs p_ty(tps,r) st
1582+
| TType_forall(tps,r)->
1583+
p_byte5 st
1584+
p_tyar_specs tps st
1585+
// Note, the "this" argument may be found in the body of a generic forall type, so propagate the isStructThisArgPos value
1586+
p_ty2 isStructThisArgPos r st
15741587
| TType_measure unt-> p_byte6 st; p_measure_expr unt st
15751588
| TType_ucase(uc,tinst)-> p_byte7 st; p_tup2 p_ucref p_tys(uc,tinst) st)
15761589

@@ -1838,9 +1851,7 @@ and p_ValData x st =
18381851
p_ranges(x.ValReprInfo|> Option.map(fun _-> x.val_range, x.DefinitionRange)) st
18391852

18401853
letisStructThisArgPos= x.IsMember&& checkForInRefStructThisArg st x.Type
1841-
st.isStructThisArgPos<- isStructThisArgPos
1842-
p_ty x.val_type st
1843-
st.isStructThisArgPos<-false
1854+
p_ty2 isStructThisArgPos x.val_type st
18441855

18451856
p_int64 x.val_flags.PickledBits st
18461857
p_option p_member_info x.MemberInfo st

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp