Skip to content

Language: String offset access and assignment ($str[$i]) (#198)#233

Merged
PurHur merged 1 commit into
masterfrom
issue-198-string-offset
May 18, 2026
Merged

Language: String offset access and assignment ($str[$i]) (#198)#233
PurHur merged 1 commit into
masterfrom
issue-198-string-offset

Conversation

@PurHur
Copy link
Copy Markdown
Owner

@PurHur PurHur commented May 18, 2026

Summary

  • VM: $str[$i] dim-fetch returns an indirect string-byte lvalue; assignment mutates the parent string in place (Zend-compatible for ASCII bytes).
  • JIT: StringOffsetHelper compiles byte load/store via LLVM GEP; echo prints single-byte offsets with %c.
  • Compliance PHPT: string_offset.phpt and string_offset_jit.phpt.

Closes #198.

Test plan

  • php bin/vm.php -r '$s="abc"; $s[1]="z"; echo $s;'azc
  • php vendor/bin/phpunit test/compliance/VMTest.php (166 tests) in php-compiler:22.04-dev container via tar pipe
  • JIT compliance when LLVM 9 bundle is available (test/compliance/JITTest.php)

Made with Cursor

Add writable string byte offsets in the VM, LLVM JIT helpers for dim fetch/assign, and compliance PHPT cases for ASCII $str[$i] access.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur PurHur merged commit a509572 into master May 18, 2026
@PurHur PurHur deleted the issue-198-string-offset branch May 18, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Language: String offset access and assignment ($str[$i])

1 participant