Materialize a non-lvalue instance before calling a helper method (Fixes #41589)

Summary

A record-valued property read is flagged nf_no_lvalue, but helper lookup passed the backing field directly as hidden Self, so a mutating helper method changed the field behind a property read while the same call on a getter worked on a copy.

Move the existing materialization of constant and address nodes into materialize_helper_instance, call it from the common consumer do_member_read, and let it accept nf_no_lvalue nodes as well: a genuine lvalue keeps its address, a non-lvalue is copied into a temporary with normal cleanup.

Fixes #41589. Test: tests/webtbs/tw41589.pp.

System

  • Operating system: all (verified on Windows 11)
  • Processor architecture: all (verified on x86-64)
  • Device: Computer

What is the current bug behavior?

A helper method called on a field-backed record property modifies the field in place; the test exits with code 3.

What is the behavior after applying this patch?

The call works on a temporary copy, as for a getter-backed property. The test exits 0.

Relevant logs and/or screenshots

Verified on x86_64-win64 main (2efddc1b): red before, green after. Also proposed to Unleashed Pascal as PR #47, which waits for this MR.

Merge request reports

Loading
Loading