Hhvm: `else if` captured too greedily by HHVM

Created on 3 Apr 2017  路  2Comments  路  Source: facebook/hhvm

Standalone code, or other way to reproduce the problem

function ifit() { echo "馃悩n": }
if (false) {}
else ifit();

https://3v4l.org/7q1Kp

Expected result

馃悩

Actual result

Parse error, unexpected T_STRING

Analysis

Same basic issue (with similar potential fix) to https://github.com/facebook/hhvm/issues/7746

When looking at the token stream in userspace: https://3v4l.org/e1Zi5 , recall that HHVM's token_get_all() turns an else if token back into three parts. Because Hacks.

Apology

Sorry about introducing that hack. You could always fix the parser not to explode at 100 chained else if blocks instead. :)

Most helpful comment

All 2 comments

Strong use of unicode in the test case, though.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fredemmott picture fredemmott  路  3Comments

karek314 picture karek314  路  6Comments

Sakretsos picture Sakretsos  路  7Comments

doublecompile picture doublecompile  路  3Comments

zkiiito picture zkiiito  路  7Comments