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

implement setproperty! for modules #44231

Merged
merged 7 commits into from Mar 14, 2022
Merged

implement setproperty! for modules #44231

merged 7 commits into from Mar 14, 2022

Conversation

simeonschaub
Copy link
Member

This replaces #44137. As discussed on triage, instead of supporting
modules in setfield!, this adds two new builtins getglobal and
setglobal! explicitly for reading and modifying module bindings. We
should probably consider getfield(::Module, ::Symbol) to be
soft-deprecated, but I don't think we want to add any warnings since
that will likely just annoy people.

@simeonschaub simeonschaub added modules status:needs tests Unit tests are required for this change labels Feb 17, 2022
@simeonschaub simeonschaub force-pushed the sds/getsetglobal branch 2 times, most recently from df33941 to ae55bf6 Compare February 19, 2022 20:34
@simeonschaub
Copy link
Member Author

I wonder whether we should also export getglobal and setglobal!?

This replaces #44137. As discussed on triage, instead of supporting
modules in `setfield!`, this adds two new builtins `getglobal` and
`setglobal!` explicitly for reading and modifying module bindings. We
should probably consider `getfield(::Module, ::Symbol)` to be
soft-deprecated, but I don't think we want to add any warnings since
that will likely just annoy people.
@simeonschaub simeonschaub added the status:triage This should be discussed on a triage call label Mar 3, 2022
@vtjnash
Copy link
Sponsor Member

vtjnash commented Mar 10, 2022

Is this done? What remains?

We export the others (fieldtype, getfield, setfield!, swapfield!, modifyfield!, replacefield!, etc) so I think it would be most consistent to export this too

@simeonschaub
Copy link
Member Author

Yes, this just needs someone to review, other than that it's done on my part.

Copy link
Sponsor Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

seems nearly complete to me

src/builtins.c Show resolved Hide resolved
src/builtins.c Outdated Show resolved Hide resolved
src/builtins.c Outdated Show resolved Hide resolved
@vtjnash vtjnash removed the status:triage This should be discussed on a triage call label Mar 11, 2022
src/builtins.c Outdated Show resolved Hide resolved
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
@vtjnash vtjnash added the status:merge me PR is reviewed. Merge when all tests are passing label Mar 11, 2022
@simeonschaub simeonschaub merged commit c38e429 into master Mar 14, 2022
@simeonschaub simeonschaub deleted the sds/getsetglobal branch March 14, 2022 23:33
@DilumAluthge DilumAluthge removed the status:merge me PR is reviewed. Merge when all tests are passing label Mar 15, 2022
@N5N3
Copy link
Member

N5N3 commented Mar 16, 2022

Looks like this PR breaks the effect inference on getfield. MWE:

g(bc) = bc.re
@descend g(1+1im)
[(+c,+e,+n,+t)]g(bc) in Main at REPL[2]:1
│ ─ %-1  = invoke g(::Complex{Int64})::Int64
1 1%1 = Base.getfield(bc, :re)::Int64                                                                                           │╻ getproperty   
  └──      return %1

After this PR:

[(+c,!e,+n,+t)]g(bc) in Main at REPL[2]:1
│ ─ %-1  = invoke g(::Complex{Int64})::Int64
1 1%1 = Base.getfield(bc, :re)::Int64                                                                                           │╻ getproperty   
  └──      return %1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
modules status:needs tests Unit tests are required for this change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants