Skip to content

__McTok (prelude tokenizer) does not lex the nullsafe operator in simple interpolation ("$a?->b"): the ?->b stays string text; Zend lexes T_NULLSAFE_OBJECT_OPERATOR + T_STRING. #383

Closed

Description

@blacktrs

Summary

__McTok (prelude tokenizer) does not lex the nullsafe operator in simple interpolation ("$a?->b"): the ?->b stays string text; Zend lexes T_NULLSAFE_OBJECT_OPERATOR + T_STRING.

Repro

<?php
// Zend:      "$a?->b" -> T_VARIABLE "$a", T_NULLSAFE_OBJECT_OPERATOR "?->", T_STRING "b"
// Manticore: "$a?->b" -> T_VARIABLE "$a", T_ENCAPSED_AND_WHITESPACE "?->b"
// Effect: explicit_string_variable wraps only `$a` (`{$a}?->b`), upstream `{$a?->b}`.
foreach (token_get_all('<?php $z = "$a?->b";') as $t) {
    echo is_array($t) ? token_name($t[0]) . json_encode($t[1]) : json_encode($t), ' ';
}
echo "\n";

Expected (php)

T_OPEN_TAG"<?php " T_VARIABLE"$z" T_WHITESPACE" " "=" T_WHITESPACE" " "\"" T_VARIABLE"$a" T_NULLSAFE_OBJECT_OPERATOR"?->" T_STRING"b" "\"" ";" 

Actual (manticore 298764a9, Darwin arm64)

T_OPEN_TAG"<?php " T_VARIABLE"$z" T_WHITESPACE" " "=" T_WHITESPACE" " "\"" T_VARIABLE"$a" T_ENCAPSED_AND_WHITESPACE"?->b" "\"" ";" 

Tracking

Known-bug repro: tests/aot/repro/wrong/tokenizer_string_nullsafe_interpolation.php — bash tests/aot/xfail.sh -k tokenizer_string_nullsafe_interpolation reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Activity

  1. added
    bug
    wrong-answer
    on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions