Skip to content

Reflect.get / Reflect.set: thread optional receiver parameter through property access pipeline #230

@coderabbitai

Description

@coderabbitai

Summary

Reflect.get and Reflect.set currently ignore the optional receiver argument. Per ES2026 §28.1.5 and §28.1.12, the receiver must be threaded through the internal [[Get]]/[[Set]] operations so that:

  • Reflect.get — if the resolved property is an accessor, the getter is called with receiver as this (defaults to target when omitted).
  • Reflect.set — if the resolved property is an accessor, the setter is called with receiver as this; for data properties, the write lands on receiver rather than target (defaults to target when omitted).

Skipping the receiver produces incorrect results for inherited setters and breaks the Proxy forwarding pattern (Reflect.set(target, prop, value, receiver) inside a set trap).

What needs to change

In units/Goccia.Builtins.GlobalReflect.pas:

  1. ReflectGet — extract AArgs.GetElement(2) as Receiver (default to Target if absent) and call TGocciaObjectValue.GetPropertyWithContext (or equivalent) instead of GetProperty/GetSymbolProperty.
  2. ReflectSet — extract the optional Receiver argument (default to Target) and thread it into the set logic via the existing OrdinarySet/SetWithContext helper so inherited setters observe the correct this.

This may require deeper changes to the property-access pipeline (GetPropertyWithContext/SetPropertyWithContext) to propagate the receiver cleanly.

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions