Skip to content

Backports for Julia 1.12-rc2 #59006

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

Merged
merged 8 commits into from
Jul 22, 2025
Merged

Backports for Julia 1.12-rc2 #59006

merged 8 commits into from
Jul 22, 2025

Conversation

KristofferC
Copy link
Member

No description provided.

mlechu and others added 8 commits July 15, 2025 15:36
Changes from #43151, github just
didn't want me to re-open it.

As discussed on slack, any `hygienic-scope` within an outer
`hygienic-scope` can read and write variables in the outer one, so it's
not particularly hygienic. The result is that we can't safely nest macro
calls unless they know the contents of all inner macro calls.

Should fix #48910.

Co-authored-by: Michiel Dral <m.c.dral@gmail.com>
(cherry picked from commit ff33305)
In d2cc061 and prior commits, we made
backdated access a conditional error (if depwarns are enabled or in
generators). However, we did not touch `isdefinedglobal`. This resulted
in the common pattern `isdefinedglobal(m, s) && getglobal(m, s)` to
sometimes error. In particular, this could be observed when attempting
to print a type from inside a generated function before that type's
definition age.

Additionally, I think the usage there, which used `invokelatest` on each
of the two queries is problematic because it is racy, since the two
`invokelatest` calls may be looking at different world ages.

This makes two tweaks:
1. Makes `isdefinedglobal` consistent with `getglobal` in that it now
returns false if `getglobal` would throw due to the above referenced
restriction.
2. Removes the implicit `invokelatest` in _isself in the show code.
Instead, it will use the current world. I considered having it use the
exception age when used for MethodErrors. However, because this is used
for printing it matters more how the object can be accessed *now* rather
than how it could have been accessed in the past.

(cherry picked from commit fb59b6d)
Co-authored-by: Andy Dienes <51664769+adienes@users.noreply.github.com>
Co-authored-by: Gabriel Baraldi <28694980+gbaraldi@users.noreply.github.com>
Co-authored-by: Diogo Netto <61364108+d-netto@users.noreply.github.com>
(cherry picked from commit 1367b3d)
…functions (#58996)

Restores something very close to the previous inlining behavior, without
reverting #54972

This is a hack to workaround
#58915 (comment)
for 1.12, but we should leave an issue open so that we can put in a
proper fix to inlining for the next major version.

Also improves
#58915 (comment),
which was a dynamic `call` on 1.11 and a poorly-chosen `invoke` of the
generator fallback on 1.12. This is now an inlined version of the
non-fallback path for the generator:
```julia
julia> nt = (next = zero(UInt32), prev = zero(UInt32))
(next = 0x00000000, prev = 0x00000000)

julia> f(nt) = @inline Base.setindex(nt, 2, :next)
f (generic function with 1 method)

julia> @code_warntype optimize=true f(nt)
MethodInstance for f(::@NamedTuple{next::UInt32, prev::UInt32})
  from f(nt) @ Main REPL[2]:1
Arguments
  #self#::Core.Const(Main.f)
  nt::@NamedTuple{next::UInt32, prev::UInt32}
Body::@NamedTuple{next::Int64, prev::UInt32}
1 ─ %1 =   builtin Base.getfield(nt, :prev)::UInt32
│   %2 = %new(@NamedTuple{next::Int64, prev::UInt32}, 2, %1)::@NamedTuple{next::Int64, prev::UInt32}
└──      return %2
```
@KristofferC
Copy link
Member Author

Will merge this to get a new 1.12-nightly but wait a bit with rc2.

@KristofferC KristofferC merged commit 51e5afe into release-1.12 Jul 22, 2025
7 checks passed
@KristofferC KristofferC deleted the backports-release-1.12 branch July 22, 2025 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants