Skip to content

Mutation of Ref embedded in Expr treated as effect-free #52843

Closed
@topolarity

Description

@topolarity

MWE in 1.10:

julia> macro foo()
          return :($ref1[] = 1; nothing)
       end
@foo (macro with 1 method)

julia> ref1 = Ref{Int}()
Base.RefValue{Int64}(140632197190944)

julia> bar() = (@foo; nothing)
bar (generic function with 1 method)

julia> bar()

julia> ref1
Base.RefValue{Int64}(140632197190944)

julia> @foo

julia> ref1
Base.RefValue{Int64}(1)

Correct output in 1.9:

julia> macro foo()
          return :($ref1[] = 1; nothing)
       end
@foo (macro with 1 method)

julia> ref1 = Ref{Int}()
Base.RefValue{Int64}(140223960686096)

julia> bar() = (@foo; nothing)
bar (generic function with 1 method)

julia> bar()

julia> ref1
Base.RefValue{Int64}(1)

julia> @foo

julia> ref1
Base.RefValue{Int64}(1)

Appears to be another variant of #52531

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler:effectseffect analysiscompiler:loweringSyntax lowering (compiler front end, 2nd stage)regressionRegression in behavior compared to a previous version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions