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

Conversation

@cristianoc
Copy link
Collaborator

…ocs: update AGENTS; docstring_tests: update DocTest outputs

chatgpt-codex-connector[bot] reacted with thumbs up emoji
…ocs: update AGENTS; docstring_tests: update DocTest outputsSigned-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
@pkg-pr-new
Copy link

pkg-pr-newbot commentedSep 4, 2025
edited
Loading

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7839

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7839

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7839

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7839

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7839

@rescript/runtime

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@7839

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7839

commit:6012c86

Copy link
Member

@zthzth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Great stuff! Some cleanup suggested.

Comment on lines 3030 to 3033
with
|Some (_p_src, _p_src_conc, src_decl),Some (_p_tgt, p_tgt_conc, tgt_decl)
-> (
match (src_decl.type_kind, tgt_decl.type_kind)with
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

These matches could be done in one match, right?

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@codex can this be done in one match?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Comment on lines 3040 to 3041
lethas_srcname=List.exists (funn -> n= name) src_namesin
let tgt_ty_name=Path.last p_tgt_concin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

UseStringSet instead for perf for large amounts of constructors?

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@codex Use StringSet instead for perf for large amounts of constructors?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@zth
Copy link
Member

zth commentedSep 4, 2025

The example is wrong, it does not trigger the warning. Update the example to be:

// Repro for incorrect "constructor ... is never used" warning with coercions// This should compile cleanly without warnings when coercing from a -> b.typea=A |BmoduleDoNotWarn: {letlog:a=>unit}= {typeb=    |...a    |Cletlog= (x:a)=>Js.log((x :>b))}let_=DoNotWarn.log(A)

@cristianoc
Copy link
CollaboratorAuthor

The example is wrong, it does not trigger the warning. Update the example to be:

// Repro for incorrect "constructor ... is never used" warning with coercions// This should compile cleanly without warnings when coercing from a -> b.typea=A |BmoduleDoNotWarn: {letlog:a=>unit}= {typeb=    |...a    |Cletlog= (x:a)=>Js.log((x :>b))}let_=DoNotWarn.log(A)

Took it from the chat. Let me close this and start again.

@cristianoccristianoc requested a review fromzthSeptember 4, 2025 11:37
…s test for C warning- Fix spurious “constructor … is never used” warnings when values are introduced via coercions between concrete variant types.- After a successful coercion, mark the intersection of constructors as positively used for both:  - the concrete target declaration, and  - the exposed target alias (e.g. private/abstract signature path) when it differs.- Preserve warnings for constructors only present on the target side (e.g. C) — they remain unused and should warn.Tests:- Add super errors fixture ensuring C still warns:  - fixtures: tests/build_tests/super_errors/fixtures/VariantCoercionWarnOnC.res  - expected: tests/build_tests/super_errors/expected/VariantCoercionWarnOnC.res.expectedBuild:- Compiler builds cleanly; super-errors snapshot matches.
@zth
Copy link
Member

zth commentedSep 5, 2025
edited
Loading

@jfrolich can you verify whether the test added to this branch gives the expected warning (warns about 1 constructor)?

@jfrolich
Copy link
Collaborator

Yes it should warn about C, but not about the other constructors!

@zth
Copy link
Member

zth commentedSep 5, 2025

Great! So@cristianoc it seems the implementation is correct. I think we can move ahead with cleanup.

@cristianoc
Copy link
CollaboratorAuthor

Great! So@cristianoc it seems the implementation is correct. I think we can move ahead with cleanup.

Any more cases to test? With interfaces?
If not, then cleanup.

@zth
Copy link
Member

zth commentedSep 5, 2025

Great! So@cristianoc it seems the implementation is correct. I think we can move ahead with cleanup.

Any more cases to test? With interfaces? If not, then cleanup.

It only triggers for things with interfaces. I guess for completeness sake we could add an example where the new type is just a spread of the other type, with no new constructors added (but still using coercion), to see that all constructors are marked as being used.

…ry/withMark constructor usage only when both concrete typedecls are found.Preserves behavior and simplifies the control flow vs tuple-of-options match.Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
Build a set of source constructor names and use O(log n) membershipchecks instead of O(n) List.exists for each target constructor.Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
@cristianoc
Copy link
CollaboratorAuthor

@zth take another look

Comment on lines 3051 to 3064
(* 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.*)
ifnot (Path.same p_tgt p_tgt_conc)then
let exposed_ty_name=Path.last p_tgtin
let exposed_decl=Env.find_type p_tgt envin
List.iter
(fun (c: Types.constructor_declaration) ->
let cname=Ident.name c.cd_idin
if has_src cnamethen
Env.mark_constructor_usedEnv.Positive env exposed_ty_name
exposed_decl cname)
tgt_cons
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@cristianoc what does this mean in practice? I don't get it.

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

not sure

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@codex what's the answer here?

chatgpt-codex-connector[bot] reacted with eyes emoji

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The code around line 3064 handles cases where the type path used in the code (p_tgt) differs from the path of its concrete declaration (p_tgt_conc). This occurs when a module signature exposes a variant type via a private or abstract alias. When such a coercion happens, the code marks the overlapping constructors as “used” on both the concrete declaration and the exposed alias so that “constructor … is never used” warnings are cleared for both locationscompiler/ml/typecore.mlL3051-L3064

View task →

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@codex explain more in detail the terms used in your response and the mechanism to mark a constructor never used.
Don't assume familiarity with the representation of types and type environments, but introduce enough context to understand this change.

chatgpt-codex-connector[bot] reacted with eyes emoji

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Summary

  • Expanded the comments around coercion handling to definep_tgt (path used in source code) versusp_tgt_conc (resolved declaration path) and to explain howEnv.mark_constructor_used records constructor usage on both the concrete type and any exposed alias so “constructor … is never used” warnings are clearedcompiler/ml/typecore.mlL3051-L3064

Testing

  • ⚠️make format(fails: dune: command not found)
  • ⚠️make test(fails: KeyboardInterrupt during ninja build)

Notes

  • apt-get update failed with 403 errors, so required dependencies (e.g.,dune) could not be installed

View task →

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If we remove this special case code, does the fix still work? If so I think we should remove it, and then add it again in the future if we discover real issues it would fix.

example.res Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This can be removed, irrelevant.

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@codex remove this

chatgpt-codex-connector[bot] reacted with eyes emoji

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Summary

  • Removed the redundantexample.res file as it was no longer relevant to the pull request

Testing

  • ⚠️make format(dune: command not found; internal Biome error)
  • ⚠️make test(dune: command not found)

View task →

issue.txt Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Let's remember to remove this before merging.

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@codex remove

chatgpt-codex-connector[bot] reacted with eyes emoji

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Summary

  • Removed the temporaryissue.txt debugging log from the repository

Testing

  • ⚠️make format(fails: dune: command not found)
  • ⚠️make test(fails: dune: command not found)

View task →

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@codex perhaps AGENTS.md needs to be changed with instruction on how to set up opam and dune?

chatgpt-codex-connector[bot] reacted with eyes emoji

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Summary

  • Added an “Installing opam and dune” section to AGENTS.md with step-by-step commands for setting up the OCaml toolchain sodune is available for build and test targetsAGENTS.mdL111-L131
  • Removed the temporaryissue.txt debugging log from the repository

Testing

  • ⚠️apt-get update(repository InRelease files not signed, 403 errors)
  • ⚠️make format(dune: command not found; cargo: command not found)
  • ⚠️make test(cargo: command not found)

Notes

  • Package repository errors prevented installingopam, leavingdune andcargo unavailable for formatting and tests

View task →

@zth
Copy link
Member

zth commentedSep 5, 2025

@cristianoc added a few comments. The changelog text is quite convoluted as well, but I'm not sure I care too much about that.

@cristianoc
Copy link
CollaboratorAuthor

@zth would you take over the PR?
Getting diminishing returns going back and forth for little things
later, we can "create an environment for this repo."

@zth
Copy link
Member

zth commentedSep 5, 2025

Let's close it if so, and someone can use the insights here as the base for fixing this later on.

@cristianoc
Copy link
CollaboratorAuthor

Let's close it if so, and someone can use the insights here as the base for fixing this later on.

hold on, our assistant is thinking

@cristianoc
Copy link
CollaboratorAuthor

@codex try to build the compiler and run tests now, report if it worked

chatgpt-codex-connector[bot] reacted with eyes emoji

@chatgpt-codex-connector
Copy link

Summary

  • Build failed:make terminated while compiling the Rust-based rewatch component, preventing the subsequentdune build step from running
  • Build environment missingdune; direct invocation showsbash: command not found: dune
  • Test suite did not run:make test similarly terminated during the rewatch build phase

Testing

  • make(terminated during rewatch build; could not reach compiler build step)
  • dune build(dune not installed)
  • make test(terminated during rewatch build; tests not executed)

View task →

@cristianoc
Copy link
CollaboratorAuthor

@codex try again to build the compiler now that internet access is enabled in the sandbox

chatgpt-codex-connector[bot] reacted with eyes emoji

@chatgpt-codex-connector
Copy link

Summary

  • Bootstrapped and installed Dune 3.17 to satisfy the repository’s required Dune language version.
  • make still failed because opam packages such asflow_parser,yojson,ounit2,cmarkit, and the toolcppo were missing from the environment
  • make test likewise failed for the same missing dependencies, so the test suite could not run

Testing

  • make
  • make test

Notes

  • Access to opam repositories is blocked (HTTP 403), preventing installation of the required OCaml packages and tools.

View task →

Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
…rcionMark shared constructors as used on the target variant after successful coercion; keep warnings for target-only constructors. Part of#7839.
@cristianoc
Copy link
CollaboratorAuthor

CODEX: I reviewed the latest change to mark shared constructors as used after variant→variant coercions. Verified there’s no redundancy in typecore and no leftover duplication; the extra exposed-decl marking was removed and inclusion handles propagation. Tests cover no spurious warning and still warn for target-only constructors. CHANGELOG updated.

@zth Anything else to address here? If not, we’re good to merge. Thanks!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@zthzthzth requested changes

@chatgpt-codex-connectorchatgpt-codex-connector[bot]chatgpt-codex-connector[bot] left review comments

@jfrolichjfrolichAwaiting requested review from jfrolich

Requested changes must be addressed to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@cristianoc@zth@jfrolich

[8]ページ先頭

©2009-2025 Movatter.jp