diff --git a/packages/babylon/src/parser/expression.js b/packages/babylon/src/parser/expression.js index d38d50ea27..391981ae28 100644 --- a/packages/babylon/src/parser/expression.js +++ b/packages/babylon/src/parser/expression.js @@ -793,9 +793,14 @@ pp.parseFunctionBody = function (node, allowExpression) { if (allowExpression) checkLVal = true; // normal function - if (!isExpression && node.body.body.length && this.isUseStrict(node.body.body[0])) { - checkLVal = true; - checkLValStrict = true; + if (!isExpression && node.body.directives.length) { + for (var directive of (node.body.directives: Array)) { + if (directive.value === "use strict") { + checkLVal = true; + checkLValStrict = true; + break; + } + } } if (checkLVal) {