-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
问题描述
如果源码里这样写:
a() !== undefined;编译出来的结果是:
isset(a());运行时就会报错,如下
Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in /path/to/file.php临时方案
通过改源码,有两种方式可解
方法1:反过来判断
源码:
undefined !== a();编译结果:
null !== a();
方法2:先赋值给变量,再判断
源码:
const b = a();
return b !== undefined;编译结果:
$b = a();
return isset($b);期望
直接编译成:新建一个临时变量,对临时变量执行 isset
大概就像 babel 对剪头函数进行转换的时候,在函数最外面先建个变量指向当前
this那种
Metadata
Metadata
Assignees
Labels
No labels