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
forked fromocaml/ocaml

Commit27132d8

Browse files
authored
flambda-backend: Fix for spurious typing error related to expanding through functor arguments (ocaml#997)
1 parent724fb68 commit27132d8

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

‎testsuite/tests/typing-modules/functors.ml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,3 +1701,47 @@ Error: The functor application Bar(A)(FiveArgsExt)(TY)(TY)(TY)(TY)(TY) is ill-ty
17011701
8.ModuleTYmatchestheexpectedmoduletypety
17021702
9.ModuleTYmatchestheexpectedmoduletypety
17031703
|}]
1704+
1705+
moduleShape_arg=struct
1706+
moduleM1 (Arg1 : sig end)=struct
1707+
module typeS1=sig
1708+
typet
1709+
end
1710+
end
1711+
1712+
module typeS2=sig
1713+
moduleMake (Arg2 : sig end) :M1(Arg2).S1
1714+
end
1715+
1716+
moduleM2 :S2=struct
1717+
moduleMake (Arg3 : sig end)=struct
1718+
typet=T
1719+
end
1720+
end
1721+
1722+
moduleM3 (Arg4 : sig end)=struct
1723+
module typeS3=sig
1724+
typet=M2.Make(Arg4).t
1725+
end
1726+
end
1727+
1728+
moduleM4 (Arg5 : sig end) :M3(Arg5).S3=struct
1729+
moduleM5=M2.Make (Arg5)
1730+
1731+
typet=M5.t
1732+
end
1733+
end
1734+
[%%expect{|
1735+
moduleShape_arg :
1736+
sig
1737+
moduleM1 :
1738+
functor (Arg1 : sig end) ->sigmoduletypeS1=sigtype tendend
1739+
module typeS2=
1740+
sigmoduleMake :functor (Arg2 : sig end) ->M1(Arg2).S1end
1741+
moduleM2 :S2
1742+
moduleM3 :
1743+
functor (Arg4 : sig end) ->
1744+
sigmoduletypeS3=sigtype t=M2.Make(Arg4).tendend
1745+
moduleM4 :functor (Arg5 : sig end) ->M3(Arg5).S3
1746+
end
1747+
|}]

‎typing/env.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,6 +2311,14 @@ and add_cltype ?shape id ty env =
23112311
let shape= shape_or_leaf ty.clty_uid shapein
23122312
store_cltype id ty shape env
23132313

2314+
letadd_module_lazy~update_summaryidpresencemtyenv=
2315+
let md=Subst.Lazy.{mdl_type= mty;
2316+
mdl_attributes=[];
2317+
mdl_loc=Location.none;
2318+
mdl_uid=Uid.internal_not_actually_unique}
2319+
in
2320+
add_module_declaration_lazy~update_summary id presence md env
2321+
23142322
letadd_module?arg?shapeidpresencemtyenv=
23152323
add_module_declaration~check:false ?arg ?shape id presence (md mty) env
23162324

‎typing/env.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ val add_extension:
302302
check:bool->rebind:bool->Ident.t ->extension_constructor ->t ->t
303303
valadd_module:?arg:bool ->?shape:Shape.t ->
304304
Ident.t ->module_presence ->module_type ->t ->t
305+
valadd_module_lazy:update_summary:bool->
306+
Ident.t ->module_presence ->Subst.Lazy.modtype ->t ->t
305307
valadd_module_declaration:?arg:bool ->?shape:Shape.t ->check:bool->
306308
Ident.t ->module_presence ->module_declaration ->t ->t
307309
valadd_module_declaration_lazy:update_summary:bool->

‎typing/mtype.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ let rec strengthen_lazy ~aliasable env mty p =
4646
MtyL_signature(strengthen_lazy_sig~aliasable env sg p)
4747
|MtyL_functor(Named (Some param, arg), res)
4848
when!Clflags.applicative_functors ->
49+
let env=
50+
Env.add_module_lazy~update_summary:false paramMp_present arg env
51+
in
4952
MtyL_functor(Named (Some param, arg),
5053
strengthen_lazy~aliasable:false env res (Papply(p,Pident param)))
5154
|MtyL_functor(Named (None, arg), res)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp