Reserved slot index of range エラー

Firefox の拡張を作っていたら奇妙なバグ(?)に遭遇。
"Reserved slot index of range" というエラーで、起きるときと起きないときがある。


I've issued a workaround for this in 3b9f4c75bb64. From the changelog:


I've narrowed down the cases in which we get the mysterious #467 ('reserved slot index out of range'). It seems to only occur when, in a closure, we assign to a variable defined with a let in an outer scope, e.g.:

function foo() {
let k;

function callMeLater() {
k = 5;
}

functionWithAsyncCallback(callMeLater);
}


Changing all such occurrences of let to var, which I'm doing in this commit, resolves the issue. But I suspect this is still a bug in SpiderMonkey that we should report.

これによると、外側のスコープでlet で値を定義しているとクロージャの中で起きるようだ。
とりあえず、:%S/let/var/g で回避できるらしい。