ECMAScript仕様輪読会 #66
前回: ECMAScript仕様輪読会 #65
Scrapboxの招待リンク: https://scrapbox.io/projects/esspec/invitations/85b96c9fa718ce5185e307196ed8fb53
connpass: https://esspec.connpass.com/
Discord: https://discord.gg/59S3y6weQj
ES Spec Draft: https://tc39.es/ecma262/
資料: https://speakerdeck.com/syumai/ecmascriptshi-yang-wodu-munonibi-yao-nazhi-shi-daiziesutoban
読み物リスト
Twitter hashtag: #esspec
便利ツール
esspec-memo: https://tars0x9752.github.io/esspec-memo/esspec.html
Scrapbox Codeblock Generator: https://vzvu3k6k.github.io/scrapbox-codeblock/
TC39 Terminology: https://github.com/tc39/how-we-work/blob/main/terminology.md
時事ネタ
自己紹介 (近況報告)
syumai syumai.icon
Twitter: https://twitter.com/__syumai GitHub: https://github.com/syumai
Go / TSを書いて暮らしてます
TSKaigi Kansai 2024のCfP通ったので話してきます
スポンサーも通ったのでブースにもいます
iwatsurut
とくに、イベントもなく過ごしています。
code:a.html
<!DOCTYPE html>A
<html>B
<head>C
<title>Title Hello !!</title>
</head>D
<body>
Hello !!
</body>E</html>F
これ、A B C D E F 全部、body の中にくりこまれることを知って驚いている。
YAMAMOTO Yuji
前回初参加
求職中です https://the.igreque.info/posts/2024/04-iij-unknown
だいたいのプロフィールは https://github.com/igrep/ に書いてます
iPad Proのディスプレイが壊れたので直したら、純正パーツじゃなかったためか音ゲーがめっちゃプレイしづらくなってしまって辛い
JSConfJPにプロポーザル出しました
yebis0942
GoとTypeScriptを書いています
PC起動しなくなったのが最新のnewsです
terashima_daisuke
初参加。英語とWebの勉強になればと
業務でWeb画面に関わっているが、Vanillaばかり
個人的にReactを触っている程度
前回のあらすじ
今回は長いので略
今回の範囲
16.2.1.1 Static Semantics: Early Errors
ModuleBody : ModuleItemList
It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries.
code:js
export const a = 1;
const b = 2;
export { b as a };
/*
export { b as a };
^^^^^^
SyntaxError: Duplicate export of 'a'
*/
It is a Syntax Error if any element of the ExportedBindings of ModuleItemList does not also occur in either the VarDeclaredNames of ModuleItemList, or the LexicallyDeclaredNames of ModuleItemList.
code:js
const a = 1;
var b = 2;
export { c };
/*
export { c };
^
SyntaxError: Export 'c' is not defined in module
*/
It is a Syntax Error if ModuleItemList Contains super.
code:js
super;
^^^^^
SyntaxError: 'super' keyword unexpected here
It is a Syntax Error if ModuleItemList Contains NewTarget.
code:js
new.target;
^^^^^^
SyntaxError: new.target expression is not allowed here
It is a Syntax Error if ContainsDuplicateLabels of ModuleItemList with argument « » is true.
code:js
a: {
a: 1;
}
/*
a: 1;
^
SyntaxError: Label 'a' has already been declared
*/
It is a Syntax Error if ContainsUndefinedBreakTarget of ModuleItemList with argument « » is true.
code:js
for (let i = 0; i < 10; i++) {
break a;
}
/*
break a;
^
SyntaxError: Undefined label 'a'
*/
code:js
// breakの意外な使い方
a: {
console.log(1);
break a;
console.log(2);
};
console.log(3);
/*
1
3
*/
It is a Syntax Error if ContainsUndefinedContinueTarget of ModuleItemList with arguments « » and « » is true.
ContainsUndefinedContinueTargetは、iterationSetとlabelSetの2つを受け取る。
continueの先は必ずIterationStatementを指している必要があるので、labelSetを区別されている。
code:js
a: {
console.log(1);
continue a;
console.log(2);
};
console.log(3);
/*
continue a;
^
SyntaxError: Illegal continue statement: 'a' does not denote an iteration statement
*/
It is a Syntax Error if AllPrivateIdentifiersValid of ModuleItemList with argument « » is false.
code:js
class C {
#a = 1;
m() {
this.#b;
}
}
/*
this.#b;
^
SyntaxError: Private field '#b' must be declared in an enclosing class
*/
NOTE
code:js
globalThis.a = 1;
export default 1;
export default 2;
/*
export default 2;
^^^^^^^^^
SyntaxError: Identifier '.default' has already been declared
*/
/*
Bun (JSC)
bun m.mjs
3 | export default 2;
^
error: Multiple exports with the same name "default"
*/
ModuleExportName : StringLiteral
It is a Syntax Error if IsStringWellFormedUnicode(SV of StringLiteral) is false.
code:js
const a = 1;
export { a as '\ud842' };
/*
export { a as '\ud842' };
^^^^^^^^
SyntaxError: Invalid module export name: contains unpaired surrogate
*/
kiesel: 実装コードに対応する言語仕様をコメントで記載している処理系
https://codeberg.org/kiesel-js/kiesel/src/commit/0be22d8d513dfd3638aa65e2f7dfd801cdef0b97/src/builtins/array.zig#L43
Static Semantics: ImportedLocalNames ( importEntries )
ImportEntry Recordsの[[localName]]を集めて返す
ImportEntry Recordとは
import v from "mod"; のように名前を付けてimportすると作られるもの
例: https://tc39.es/ecma262/#table-import-forms-mapping-to-importentry-records
Static Semantics: ModuleRequests
ModuleをたどってModuleSpecifierを集めて返す
code:js