Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overwriting typing #3157

Merged
merged 36 commits into from
Nov 27, 2024
Merged

Conversation

anfelor
Copy link
Contributor

@anfelor anfelor commented Oct 17, 2024

This PR contains the type checking code for the overwriting extension.

The translation in translcore.ml is not implemented, that is every testcase that currently prints with Alert Translcore actually type-checks successfully.

Copy link

github-actions bot commented Oct 17, 2024

Parser Change Checklist

This PR modifies the parser. Please check that the following tests are updated:

  • parsetree/source_jane_street.ml

This test should have examples of every new bit of syntax you are adding. Feel free to just check the box if your PR does not actually change the syntax (because it is refactoring the parser, say).

@anfelor anfelor requested a review from goldfirere October 17, 2024 22:01
Copy link
Collaborator

@goldfirere goldfirere left a comment

Choose a reason for hiding this comment

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

Reviewed everything except uniqueness_analysis.ml, which I will get to next. Happy to talk about anything I brought up here!

ocaml/testsuite/tests/typing-unique/overwriting.ml Outdated Show resolved Hide resolved
ocaml/testsuite/tests/typing-unique/overwriting.ml Outdated Show resolved Hide resolved
ocaml/testsuite/tests/typing-unique/overwriting.ml Outdated Show resolved Hide resolved
ocaml/typing/typecore.ml Outdated Show resolved Hide resolved
ocaml/typing/typecore.ml Outdated Show resolved Hide resolved
ocaml/typing/typecore.ml Show resolved Hide resolved
ocaml/typing/typecore.ml Outdated Show resolved Hide resolved
ocaml/typing/value_rec_check.ml Show resolved Hide resolved
ocaml/typing/typecore.ml Outdated Show resolved Hide resolved
ocaml/typing/typecore.ml Outdated Show resolved Hide resolved
Copy link
Collaborator

@goldfirere goldfirere left a comment

Choose a reason for hiding this comment

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

Finished reviewing uniqueness_analysis.ml

ocaml/typing/uniqueness_analysis.ml Outdated Show resolved Hide resolved
ocaml/typing/uniqueness_analysis.ml Outdated Show resolved Hide resolved
ocaml/typing/uniqueness_analysis.ml Outdated Show resolved Hide resolved
ocaml/typing/uniqueness_analysis.ml Show resolved Hide resolved
ocaml/typing/uniqueness_analysis.ml Outdated Show resolved Hide resolved
ocaml/typing/typecore.ml Outdated Show resolved Hide resolved
ocaml/typing/typecore.ml Outdated Show resolved Hide resolved
ocaml/typing/typecore.ml Outdated Show resolved Hide resolved
ocaml/testsuite/tests/typing-unique/overwriting.ml Outdated Show resolved Hide resolved
ocaml/typing/uniqueness_analysis.ml Show resolved Hide resolved
@anfelor
Copy link
Contributor Author

anfelor commented Oct 30, 2024

@riaqn is adopting my comments about the uniqueness analysis in #3197, I'll remove them from here for now to reduce merge conflicts later.

Copy link
Collaborator

@goldfirere goldfirere left a comment

Choose a reason for hiding this comment

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

Reviewed only the change to the tests -- I want to make sure we agree on the specification of what this is supposed to do before diving into the implementation. In particular, I'm worried about the case where a mutation on an untaken branch matters; that suggests to me that something is slightly off here.

ocaml/testsuite/tests/typing-unique/overwriting.ml Outdated Show resolved Hide resolved
ocaml/typing/typecore.ml Show resolved Hide resolved
ocaml/typing/uniqueness_analysis.ml Outdated Show resolved Hide resolved
ocaml/testsuite/tests/typing-unique/overwriting.ml Outdated Show resolved Hide resolved
ocaml/testsuite/tests/typing-unique/overwriting.ml Outdated Show resolved Hide resolved
@goldfirere
Copy link
Collaborator

Somehow that last slate of comments included some stale ones that I must have forgotten to push

@goldfirere
Copy link
Collaborator

I've reviewed the test changes in the last three commits. Looks good! I think I will be able to review the new bits in uniqueness analysis today.

Copy link
Collaborator

@goldfirere goldfirere left a comment

Choose a reason for hiding this comment

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

🎉

ocaml/typing/uniqueness_analysis.ml Show resolved Hide resolved
ocaml/typing/uniqueness_analysis.ml Show resolved Hide resolved
ocaml/typing/uniqueness_analysis.ml Outdated Show resolved Hide resolved
ocaml/typing/uniqueness_analysis.ml Show resolved Hide resolved
ocaml/typing/uniqueness_analysis.ml Outdated Show resolved Hide resolved
ocaml/typing/uniqueness_analysis.ml Show resolved Hide resolved
ocaml/typing/uniqueness_analysis.ml Outdated Show resolved Hide resolved
ocaml/typing/uniqueness_analysis.ml Show resolved Hide resolved
ocaml/typing/uniqueness_analysis.ml Outdated Show resolved Hide resolved
ocaml/typing/uniqueness_analysis.ml Outdated Show resolved Hide resolved
@goldfirere
Copy link
Collaborator

This looks ready for merging to me. 🎆 (but I don't want to click the button in case there's something I'm missing)

@anfelor anfelor merged commit 3fa276a into ocaml-flambda:overwriting Nov 27, 2024
17 checks passed
@anfelor anfelor deleted the overwriting-typing branch November 27, 2024 19:02
anfelor added a commit to anfelor/flambda-backend that referenced this pull request Nov 27, 2024
* First draft of type checking

* Check in uniqueness analysis that tags stay the same during overwriting

* Report a syntax error on overwriting anything except an allocation

* Full type-checking for tuples and records

* Type checking fully implemented

* Clean up type-checking and add ability to overwrite arbitrary expressions

* Fix checking of tags

* Test (labeled) tuples

* Final tests and allow overwrite of inlined records

* Review suggestion

Co-authored-by: Richard Eisenberg <[email protected]>

* Review suggestion

Co-authored-by: Richard Eisenberg <[email protected]>

* Review feedback: add more tests

* Uniqueness analysis: Change grammar of error message to indicate parallel evaluation

* Review feedback: Fix typo

Co-authored-by: Richard Eisenberg <[email protected]>

* Review feedback: add comments and tests

* Prevent nested allocations in overwrite

* Review feedback: Fix comment and improve readability

* Review feedback: add comments, tests and nicer error messages

* Fix nested record bug

* Improve code quality

* Disallow overwriting of unboxed records

* Review feedback

* Clarify the overwriting state for type_label_exp

* Add debugging printers for uniqueness

Sadly this doesn't actually work in the debugger.

* Temporarily allow unique mutable fields for better tests of overwriting tags (to be reverted)

* New scheme for checking that overwrite does not change tags

* Refactor: split up Learned_tags and Overwrites and use match_with_learned_tags instead of seq

* Add comment about fold_left1 and zero of semiring

* Fix submode error attribution in records

* Tune errors in tag checker

* Don't record tags that have been overwritten and matched with a learned tag

* Review feedback: comments and small improvements

* Review feedback: tune comments

---------

Co-authored-by: Richard Eisenberg <[email protected]>
Co-authored-by: Richard Eisenberg <[email protected]>
@anfelor
Copy link
Contributor Author

anfelor commented Nov 27, 2024

Post merge: We accidentally forgot to revert c29a7bb. This enables unique mutable record fields but we do not want to enable this feature yet (and it is unclear what other safeguards we need to implement). This change was separately reverted in be5eded. If you plan on using the code from this PR, please make sure to also include that commit.

anfelor added a commit to anfelor/flambda-backend that referenced this pull request Dec 3, 2024
* First draft of type checking

* Check in uniqueness analysis that tags stay the same during overwriting

* Report a syntax error on overwriting anything except an allocation

* Full type-checking for tuples and records

* Type checking fully implemented

* Clean up type-checking and add ability to overwrite arbitrary expressions

* Fix checking of tags

* Test (labeled) tuples

* Final tests and allow overwrite of inlined records

* Review suggestion

Co-authored-by: Richard Eisenberg <[email protected]>

* Review suggestion

Co-authored-by: Richard Eisenberg <[email protected]>

* Review feedback: add more tests

* Uniqueness analysis: Change grammar of error message to indicate parallel evaluation

* Review feedback: Fix typo

Co-authored-by: Richard Eisenberg <[email protected]>

* Review feedback: add comments and tests

* Prevent nested allocations in overwrite

* Review feedback: Fix comment and improve readability

* Review feedback: add comments, tests and nicer error messages

* Fix nested record bug

* Improve code quality

* Disallow overwriting of unboxed records

* Review feedback

* Clarify the overwriting state for type_label_exp

* Add debugging printers for uniqueness

Sadly this doesn't actually work in the debugger.

* Temporarily allow unique mutable fields for better tests of overwriting tags (to be reverted)

* New scheme for checking that overwrite does not change tags

* Refactor: split up Learned_tags and Overwrites and use match_with_learned_tags instead of seq

* Add comment about fold_left1 and zero of semiring

* Fix submode error attribution in records

* Tune errors in tag checker

* Don't record tags that have been overwritten and matched with a learned tag

* Review feedback: comments and small improvements

* Review feedback: tune comments

---------

Co-authored-by: Richard Eisenberg <[email protected]>
Co-authored-by: Richard Eisenberg <[email protected]>
anfelor added a commit to anfelor/flambda-backend that referenced this pull request Dec 5, 2024
* First draft of type checking

* Check in uniqueness analysis that tags stay the same during overwriting

* Report a syntax error on overwriting anything except an allocation

* Full type-checking for tuples and records

* Type checking fully implemented

* Clean up type-checking and add ability to overwrite arbitrary expressions

* Fix checking of tags

* Test (labeled) tuples

* Final tests and allow overwrite of inlined records

* Review suggestion

Co-authored-by: Richard Eisenberg <[email protected]>

* Review suggestion

Co-authored-by: Richard Eisenberg <[email protected]>

* Review feedback: add more tests

* Uniqueness analysis: Change grammar of error message to indicate parallel evaluation

* Review feedback: Fix typo

Co-authored-by: Richard Eisenberg <[email protected]>

* Review feedback: add comments and tests

* Prevent nested allocations in overwrite

* Review feedback: Fix comment and improve readability

* Review feedback: add comments, tests and nicer error messages

* Fix nested record bug

* Improve code quality

* Disallow overwriting of unboxed records

* Review feedback

* Clarify the overwriting state for type_label_exp

* Add debugging printers for uniqueness

Sadly this doesn't actually work in the debugger.

* Temporarily allow unique mutable fields for better tests of overwriting tags (to be reverted)

* New scheme for checking that overwrite does not change tags

* Refactor: split up Learned_tags and Overwrites and use match_with_learned_tags instead of seq

* Add comment about fold_left1 and zero of semiring

* Fix submode error attribution in records

* Tune errors in tag checker

* Don't record tags that have been overwritten and matched with a learned tag

* Review feedback: comments and small improvements

* Review feedback: tune comments

---------

Co-authored-by: Richard Eisenberg <[email protected]>
Co-authored-by: Richard Eisenberg <[email protected]>
anfelor added a commit that referenced this pull request Dec 6, 2024
* Basic overwriting syntax (#3089)

* Basic overwriting syntax

* Update line numbers in expect tests after cherry-pick

* Implement suggestions

* Update tests

* Implement suggestions

* Remove nested quotes

* Revert "Remove nested quotes"

This reverts commit 72eaa04.

* Overwriting tests (#3123)

* Tests for overwriting

* Remove old tests for unique overwrites and fix typos

* Add overwriting tests back

* Add tests for lifting out constants

* Update tests

* Use extension universe alpha

* Test all cases for gc soundness bug

* Review feedback: add more CRs and clarify overwriting_map.ml

* Review feedback: Add allocation counter to rbtree

* Review feedback: also test mixed blocks and unboxed float blocks in the lift constants test

* Review feedback: as discussed in meeting

* Review feedback

* Overwriting typing (#3157)

* First draft of type checking

* Check in uniqueness analysis that tags stay the same during overwriting

* Report a syntax error on overwriting anything except an allocation

* Full type-checking for tuples and records

* Type checking fully implemented

* Clean up type-checking and add ability to overwrite arbitrary expressions

* Fix checking of tags

* Test (labeled) tuples

* Final tests and allow overwrite of inlined records

* Review suggestion

Co-authored-by: Richard Eisenberg <[email protected]>

* Review suggestion

Co-authored-by: Richard Eisenberg <[email protected]>

* Review feedback: add more tests

* Uniqueness analysis: Change grammar of error message to indicate parallel evaluation

* Review feedback: Fix typo

Co-authored-by: Richard Eisenberg <[email protected]>

* Review feedback: add comments and tests

* Prevent nested allocations in overwrite

* Review feedback: Fix comment and improve readability

* Review feedback: add comments, tests and nicer error messages

* Fix nested record bug

* Improve code quality

* Disallow overwriting of unboxed records

* Review feedback

* Clarify the overwriting state for type_label_exp

* Add debugging printers for uniqueness

Sadly this doesn't actually work in the debugger.

* Temporarily allow unique mutable fields for better tests of overwriting tags (to be reverted)

* New scheme for checking that overwrite does not change tags

* Refactor: split up Learned_tags and Overwrites and use match_with_learned_tags instead of seq

* Add comment about fold_left1 and zero of semiring

* Fix submode error attribution in records

* Tune errors in tag checker

* Don't record tags that have been overwritten and matched with a learned tag

* Review feedback: comments and small improvements

* Review feedback: tune comments

---------

Co-authored-by: Richard Eisenberg <[email protected]>
Co-authored-by: Richard Eisenberg <[email protected]>

* Revert c29a7bb to disable unique mutable fields again

* Remove out-of-date CRs

---------

Co-authored-by: Richard Eisenberg <[email protected]>
Co-authored-by: Richard Eisenberg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants