Skip to content

Nested begin/end indexing no longer supported #23

@torfjelde

Description

@torfjelde

Back in the day, doing something like x[1][end] was possible, but it no longer is:

julia> AbstractPPL.vinds(:(x[1][end]))
:((((lastindex)(var"##S#319"),),))

which references an undefined variable. This is because of the Base.replace_ref_begin_end!:

julia> Base.replace_ref_begin_end!(:(x[1][end]))
:(let var"##S#320" = x[1]
      var"##S#320"[(lastindex)(var"##S#320")]
  end)

which is then further altered afterwards in

@static if VERSION < v"1.5.0-DEV.666"
Base.replace_ref_end!(ex)
else
Base.replace_ref_begin_end!(ex)
end
last = Expr(:tuple, ex.args[2:end]...)
init = vinds(ex.args[1]).args
return Expr(:tuple, init..., last)

resulting in the incorrect generated code.

Is this intended?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions