Skip to content

pointerof should allow ReadInstanceVar on self #16647

@HertzDevil

Description

@HertzDevil

It is currently a syntax error if the first token of the argument to pointerof is a self:

class Foo
  @x : Int32

  def foo
    pointerof(self)    # Error: can't take address of self
    pointerof(self.@x) # Error: can't take address of self
  end
end

There is, however, nothing wrong with the second line; if you can take a pointer to a different instance's ivar, i.e. bar = Foo.new; pointerof(bar.@x), and self.@x works outside pointerof, then it makes sense that pointerof(self.@x) should be equivalent to pointerof(@x) in the above example.

(This is only about ReadInstanceVar and should not be confused with #15903.)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions