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

compiler: update typecore; tests: add VariantCoercionConstructUsed; d…#7839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
cristianoc wants to merge8 commits intomaster
base:master
Choose a base branch
Loading
fromcodex-on-issue-7838
Open
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
typecore: avoid false 'constructor … is never used' after variant coe…
…rcionMark shared constructors as used on the target variant after successful coercion; keep warnings for target-only constructors. Part of#7839.
  • Loading branch information
@cristianoc
cristianoc committedSep 6, 2025
commit7da7c056cc92ecfa2b11e189283a7720d56a6ef7
20 changes: 2 additions & 18 deletionscompiler/ml/typecore.ml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3026,9 +3026,7 @@ and type_expect_ ~context ?in_function ?(recarg = Rejected) env sexp ty_expected
let _p_src, _p_src_conc, src_decl =
Ctype.extract_concrete_typedecl env arg.exp_type
in
let p_tgt, p_tgt_conc, tgt_decl =
Ctype.extract_concrete_typedecl env ty'
in
let _, p_tgt_conc, tgt_decl = Ctype.extract_concrete_typedecl env ty' in
match (src_decl.type_kind, tgt_decl.type_kind) with
| Type_variant src_cons, Type_variant tgt_cons ->
let module StringSet = Set.Make (String) in
Expand All@@ -3047,21 +3045,7 @@ and type_expect_ ~context ?in_function ?(recarg = Rejected) env sexp ty_expected
if has_src cname then
Env.mark_constructor_used Env.Positive env tgt_ty_name_conc
tgt_decl cname)
tgt_cons;
(* If the target type path differs from its concrete decl (e.g.,
when a signature exposes a private or abstract alias), also mark
usage on the exposed target declaration so scheduled warnings
attached to that declaration are cleared. *)
if not (Path.same p_tgt p_tgt_conc) then
let exposed_ty_name = Path.last p_tgt in
let exposed_decl = Env.find_type p_tgt env in
List.iter
(fun (c : Types.constructor_declaration) ->
let cname = Ident.name c.cd_id in
if has_src cname then
Env.mark_constructor_used Env.Positive env exposed_ty_name
exposed_decl cname)
tgt_cons
tgt_cons
| _ -> ()
with Not_found -> ());
rue
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp