Fix errors with strict lookup in compat mode (#2150)
Fixes #2149, fixes #1741
This commit is contained in:
@@ -1175,20 +1175,34 @@ function strictLookup(requireTerminal, compiler, parts, startPartIndex, type) {
|
||||
stack = compiler.nameLookup(stack, parts[i], type);
|
||||
}
|
||||
|
||||
if (requireTerminal) {
|
||||
if (!requireTerminal) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
if (startPartIndex > len) {
|
||||
// Compat mode already consumed all parts via depthedLookup; the stack
|
||||
// holds the resolved value, not an object to look the property up on.
|
||||
// Use container.strictLookup to traverse depths with a strict error on miss.
|
||||
return [
|
||||
compiler.aliasable('container.strict'),
|
||||
'(',
|
||||
stack,
|
||||
', ',
|
||||
compiler.aliasable('container.strictLookup'),
|
||||
'(depths, ',
|
||||
compiler.quotedString(parts[len]),
|
||||
', ',
|
||||
JSON.stringify(compiler.source.currentLocation),
|
||||
' )',
|
||||
];
|
||||
} else {
|
||||
return stack;
|
||||
}
|
||||
|
||||
return [
|
||||
compiler.aliasable('container.strict'),
|
||||
'(',
|
||||
stack,
|
||||
', ',
|
||||
compiler.quotedString(parts[len]),
|
||||
', ',
|
||||
JSON.stringify(compiler.source.currentLocation),
|
||||
' )',
|
||||
];
|
||||
}
|
||||
|
||||
export default JavaScriptCompiler;
|
||||
|
||||
Reference in New Issue
Block a user