Commit bd7f4823 authored by jameslahm's avatar jameslahm Committed by V8 LUCI CQ

[error] Improve GetExport error message

According to https://tc39.es/ecma262/#sec-InnerModuleLinking
step 10 and https://tc39.es/ecma262/#sec-source-text-module-record-initialize-environment
step 8-25, variables must be declared in Link. And according
to https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-get-p-receiver,
accessing the exported variable with the hole value should
throw uninitialized error.

Bug: v8:12729
Change-Id: I6fd2fcc580f7bafca986448b37adb8ba8f077929
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3552281Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79637}
parent 959dd7d5
......@@ -376,8 +376,16 @@ MaybeHandle<Object> JSModuleNamespace::GetExport(Isolate* isolate,
Handle<Object> value(Cell::cast(*object).value(), isolate);
if (value->IsTheHole(isolate)) {
THROW_NEW_ERROR(
isolate, NewReferenceError(MessageTemplate::kNotDefined, name), Object);
// According to https://tc39.es/ecma262/#sec-InnerModuleLinking
// step 10 and
// https://tc39.es/ecma262/#sec-source-text-module-record-initialize-environment
// step 8-25, variables must be declared in Link. And according to
// https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-get-p-receiver,
// here accessing uninitialized variable error should be throwed.
THROW_NEW_ERROR(isolate,
NewReferenceError(
MessageTemplate::kAccessedUninitializedVariable, name),
Object);
}
return value;
......
// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {getNS} from 'regress-v8-12729.mjs';
assertThrows(
getNS, ReferenceError, 'Cannot access \'default\' before initialization');
export default 0;
// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import * as ns from 'regress-v8-12729-1.mjs';
export function getNS() {
return Object.keys(ns);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment