kphp icon indicating copy to clipboard operation
kphp copied to clipboard

Nice error message for finally

Open vajexal opened this issue 3 years ago • 0 comments

Consider simple script

<?php

try {
    throw new Exception('here we go');
} catch (Exception $e) {
    echo $e->getMessage(), PHP_EOL;
} finally {
    echo "finally\n";
}

for now finally keyword gives strange error message

Compilation error at stage: Parse file, gen by gentree.cpp:314
  t.php:8
    echo "finally\n ";

Expected '}', found 'echo'


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compilation error at stage: Parse file, gen by gentree.cpp:1577
  t.php:8
    echo "finally\n ";

Failed to parse statement. Expected `;`

line 9: something wrong

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compilation error at stage: Parse file, gen by gentree.cpp:2251
  t.php:9
    }

Cannot compile (probably problems with brace balance)

Compilation terminated due to errors

this pr adds nice error message for finally keyword

Compilation error at stage: Parse file, gen by gentree.cpp:2080
  t.php:7
    } finally {

finally is unsupported

Compilation terminated due to errors

vajexal avatar Feb 08 '22 23:02 vajexal