Skip to content

feat: add names to modules#375

Merged
mergify[bot] merged 8 commits intomainfrom
brprice/module-names
Apr 25, 2022
Merged

feat: add names to modules#375
mergify[bot] merged 8 commits intomainfrom
brprice/module-names

Conversation

@brprice
Copy link
Copy Markdown
Contributor

@brprice brprice commented Apr 11, 2022

No description provided.

@brprice brprice force-pushed the brprice/module-names branch 2 times, most recently from 5fbbe33 to 460cbf1 Compare April 11, 2022 14:58
@brprice brprice linked an issue Apr 11, 2022 that may be closed by this pull request
@brprice
Copy link
Copy Markdown
Contributor Author

brprice commented Apr 11, 2022

Tracking comment for progress towards implementing the FR (I may split this out into a new pr):

Notes for reviewers:
This is an annoyingly large PR, but much of it is mechanical. It may be sensible to split it after the commit "refactor: use modules where possible", as the initial commits are some refactoring to set up, and the last commit is a large one that touches everywhere a global name is modified, to add a module prefix.
The pr will not pass CI due to an intentionally failing test that I have opened a thread about below.

@brprice brprice force-pushed the brprice/module-names branch from a822e8b to c6582b5 Compare April 11, 2022 16:17
Base automatically changed from brprice/refactor-internalerror-text to main April 11, 2022 16:33
@brprice brprice force-pushed the brprice/module-names branch from 93d9334 to d1b6d42 Compare April 12, 2022 14:40
Comment thread primer/src/Primer/Core/Transform.hs
Comment thread primer/src/Primer/Module.hs
Comment thread primer/src/Primer/Typecheck.hs
@brprice brprice force-pushed the brprice/module-names branch from 1f01f65 to c825e81 Compare April 12, 2022 15:14
Comment thread primer/test/Tests/Action/Prog.hs Outdated
Comment thread primer/test/Tests/Action/Prog.hs Outdated
Comment thread primer/test/Tests/Action/Prog.hs Outdated
@brprice brprice requested a review from a team April 12, 2022 15:30
@brprice brprice marked this pull request as ready for review April 12, 2022 15:33
@brprice brprice removed a link to an issue Apr 13, 2022
@georgefst
Copy link
Copy Markdown
Contributor

Note that we should update the comment about checking all modules in applyProgAction's RenameType case.

See #367 (comment).

@brprice brprice force-pushed the brprice/module-names branch from 69338cc to 7fa6b30 Compare April 19, 2022 14:54
@brprice brprice changed the base branch from main to brprice/extendTypeDefCxt April 19, 2022 14:54
@brprice brprice force-pushed the brprice/module-names branch from 00408ed to 2e774fc Compare April 19, 2022 16:42
@brprice brprice force-pushed the brprice/module-names branch from 8aa5dcf to 69b7753 Compare April 19, 2022 19:07
Comment thread primer/src/Primer/Typecheck.hs Outdated
@brprice brprice force-pushed the brprice/module-names branch from 39cf2ca to 496a7ea Compare April 19, 2022 19:48
Comment thread primer/src/Primer/Builtins.hs Outdated
Comment thread primer/src/Primer/Typecheck.hs Outdated
Comment thread primer/test/Tests/Action/Prog.hs Outdated
Base automatically changed from brprice/extendTypeDefCxt to main April 20, 2022 14:55
@brprice brprice force-pushed the brprice/module-names branch 2 times, most recently from 53cddae to e2324fe Compare April 22, 2022 17:15
@brprice brprice force-pushed the brprice/module-names branch 2 times, most recently from dc6bd83 to f19282a Compare April 25, 2022 12:14
brprice added 4 commits April 25, 2022 13:25
This is in preperation for adding module names, which will require some
renaming of primitives.  We will export some identifiers for these names
instead of writing them as literal strings, to make any future renames
easier.
This is in preperation for adding module names, which will require some
renaming of primitives.
This is not yet needed, as currently primitive types are always in scope
-- the '...WithPrims' just adds primitive terms. But this will change
shortly.
@brprice brprice force-pushed the brprice/module-names branch from 83602e5 to ec61235 Compare April 25, 2022 12:41
Instead of using 'defaultTypeDefs', define and use 'builtinModule' and
'primitiveModule'. This is in preparation for adding module names and
taking modules more seriously.

There is one theoretical drawback: in Tests.EvalFull we lose the ability
to generate definitions for global variables. However, we never actually
used this ability, so there is no loss in practice. (However, we may
want to re-instate this ability in the future so we can generate an
arbitrary context in these tests.)
@brprice brprice force-pushed the brprice/module-names branch from 2d190c7 to d3bc436 Compare April 25, 2022 13:32
@brprice
Copy link
Copy Markdown
Contributor Author

brprice commented Apr 25, 2022

After rebasing this onto main, I am seeing sporadic CI failures in type_preservation, e.g.

Use '--hedgehog-replay "Size 37 Seed 10684577349138219122 13324058589961643495"' to reproduce.
Use -p '$0=="test/Test.hs.Tests.EvalFull.type preservation"' to rerun this test only.

https://buildkite.com/hackworthltd/primer/builds/514#d236758d-3a20-4f3a-815b-d38e61c81420
I will investigate before merging, but given that it happened on the very first commit, I expect it is a pre-existing bug.

brprice added 2 commits April 25, 2022 14:39
This is a large commit, but most of it is pretty mechanical.

NB: we remove the test 'unit_rename_def_capture'. It tested that we
could not rename a definition in such a way that a reference would be
captured by a local binding. However, now that global variables have
module-qualified names, this is no longer possible: a local binding is
not considered to shadow any globals.

BREAKING CHANGE: this change requires a database migration, as it
changes the representation of `Prog`. However, since this is just
serialised to json and stored as a blob in the DB, it requires no schema
changes. Since we have no programs we need to preserve, we decided not
to bother with a migration. This means that DBs created before this
commit will not load with a primer containing this commit.
@brprice
Copy link
Copy Markdown
Contributor Author

brprice commented Apr 25, 2022

After rebasing this onto main, I am seeing sporadic CI failures in type_preservation

This is indeed a pre-existing bug. I'll track this in #407.

Let's merge this PR -- I retried CI and it now passes (the failing test is a hedgehog test which only sporadically fails)

@brprice brprice added the Ready to merge Ready to merge label Apr 25, 2022
@mergify mergify Bot merged commit 5f8b303 into main Apr 25, 2022
@mergify mergify Bot deleted the brprice/module-names branch April 25, 2022 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready to merge Ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants