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

Commitd636c94

Browse files
dsymeKevinRansom
authored andcommitted
fix binary compat problem for inref struct pointers (#5388)
1 parente8228c3 commitd636c94

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

‎src/fsharp/TastPickle.fs‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ type WriterState =
121121
onlerefs:Table<int* int[]>
122122
osimpletys:Table<int>
123123
oglobals:TcGlobals
124+
mutable isStructThisArgPos:bool
124125
ofile:string
125126
/// Indicates if we are using in-memory format, where we store XML docs as well
126127
oInMem:bool
@@ -709,7 +710,8 @@ let pickleObjWithDanglingCcus inMem file g scope p x =
709710
osimpletys=Table<_>.Create"osimpletys"
710711
oglobals=g
711712
ofile=file
712-
oInMem=inMem}
713+
oInMem=inMem
714+
isStructThisArgPos=false}
713715
p x st1
714716
letsizes=
715717
st1.otycons.Size,
@@ -731,7 +733,8 @@ let pickleObjWithDanglingCcus inMem file g scope p x =
731733
osimpletys=Table<_>.Create"osimpletys (fake)"
732734
oglobals=g
733735
ofile=file
734-
oInMem=inMem}
736+
oInMem=inMem
737+
isStructThisArgPos=false}
735738
p_tup7
736739
(p_array p_encoded_ccuref)
737740
(p_tup3 p_int p_int p_int)
@@ -1268,6 +1271,13 @@ let p_tys = (p_list p_ty)
12681271

12691272
letfill_p_attribs,p_attribs= p_hole()
12701273

1274+
// In F# 4.5, the type of the "this" pointer for structs is considered to be inref for the purposes of checking the implementation
1275+
// of the struct. However for backwards compat reaons we can't serialize this as the type.
1276+
letcheckForInRefStructThisArg st ty=
1277+
letg= st.oglobals
1278+
let_,tauTy= tryDestForallTy g ty
1279+
isFunTy g tauTy&& isFunTy g(rangeOfFunTy g tauTy)&& isInByrefTy g(domainOfFunTy g tauTy)
1280+
12711281
letp_nonlocal_val_ref(nlv:NonLocalValOrMemberRef)st=
12721282
leta= nlv.EnclosingEntity
12731283
letkey= nlv.ItemKey
@@ -1277,7 +1287,13 @@ let p_nonlocal_val_ref (nlv:NonLocalValOrMemberRef) st =
12771287
p_bool pkey.MemberIsOverride st
12781288
p_string pkey.LogicalName st
12791289
p_int pkey.TotalArgCount st
1290+
letisStructThisArgPos=
1291+
match key.TypeForLinkagewith
1292+
| None->false
1293+
| Some ty-> checkForInRefStructThisArg st ty
1294+
st.isStructThisArgPos<- isStructThisArgPos
12801295
p_option p_ty key.TypeForLinkage st
1296+
st.isStructThisArgPos<-false
12811297

12821298
let recp_vref ctxt x st=
12831299
match xwith
@@ -1539,6 +1555,7 @@ let u_tyar_specs = (u_list u_tyar_spec)
15391555

15401556
let_= fill_p_ty(fun ty st->
15411557
letty= stripTyparEqns ty
1558+
letty=if isInByrefTy st.oglobals ty&& st.isStructThisArgPosthen destByrefTy st.oglobals tyelse ty
15421559
match tywith
15431560
| TType_tuple(tupInfo,l)->
15441561
if evalTupInfoIsStruct tupInfothen
@@ -1547,7 +1564,11 @@ let _ = fill_p_ty (fun ty st ->
15471564
p_byte0 st; p_tys l st
15481565
| TType_app(ERefNonLocal nleref,[])-> p_byte1 st; p_simpletyp nleref st
15491566
| TType_app(tc,tinst)-> p_byte2 st; p_tup2(p_tcref"typ") p_tys(tc,tinst) st
1550-
| TType_fun(d,r)-> p_byte3 st; p_tup2 p_ty p_ty(d,r) st
1567+
| TType_fun(d,r)->
1568+
p_byte3 st
1569+
p_ty d st
1570+
st.isStructThisArgPos<-false
1571+
p_ty r st
15511572
| TType_var r-> p_byte4 st; p_tpref r st
15521573
| TType_forall(tps,r)-> p_byte5 st; p_tup2 p_tyar_specs p_ty(tps,r) st
15531574
| TType_measure unt-> p_byte6 st; p_measure_expr unt st
@@ -1815,7 +1836,12 @@ and p_ValData x st =
18151836
p_option p_string x.ValCompiledName st
18161837
// only keep range information on published values, not on optimization data
18171838
p_ranges(x.ValReprInfo|> Option.map(fun _-> x.val_range, x.DefinitionRange)) st
1839+
1840+
letisStructThisArgPos= x.IsMember&& checkForInRefStructThisArg st x.Type
1841+
st.isStructThisArgPos<- isStructThisArgPos
18181842
p_ty x.val_type st
1843+
st.isStructThisArgPos<-false
1844+
18191845
p_int64 x.val_flags.PickledBits st
18201846
p_option p_member_info x.MemberInfo st
18211847
p_attribs x.Attribs st

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp