From d18a3b5d4763e7e574ff9b48d65edee5e0060877 Mon Sep 17 00:00:00 2001 From: Daniel Minor Date: Thu, 23 Oct 2025 13:13:45 -0400 Subject: [PATCH 1/3] Use internal slot to store the stack trace Fixes #12 --- spec.emu | 72 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 8 deletions(-) diff --git a/spec.emu b/spec.emu index e603cc6..eb5b653 100644 --- a/spec.emu +++ b/spec.emu @@ -41,6 +41,48 @@ markEffects: true + +

Well-Known Intrinsic Objects

+ + + + + + + + + + + + + + + + + + + + +
+ Intrinsic Name + + Global Name + + ECMAScript Language Association +
+ %ErrorCaptureStackTraceGetter% + + + The getter installed by `Error.captureStackTrace` () +
+ %ErrorCaptureStackTraceSetter% + + + The setter installed by `Error.captureStackTrace` () +
+
+
+

Fundamental Objects

@@ -66,17 +108,31 @@ markEffects: true 1. Perform ? DefinePropertyOrThrow(_O_, *"stack"*, PropertyDescriptor { [[Value]]: _string_, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }). 1. Else, 1. Assert: _strategy_ is ~accessor~. - 1. Let _getterClosure_ be a new Abstract Closure with no parameters that captures _string_ and performs the following steps when called: - 1. Return NormalCompletion(_string_). - 1. Let _getter_ be CreateBuiltinFunction(_getterClosure_, 0, "", « »). - 1. Let _setterClosure_ be a new Abstract Closure with parameters (_value_) that captures _O_ and performs the following steps when called: - 1. Perform ? DefinePropertyOrThrow(_O_, *"stack"*, PropertyDescriptor { [[Value]]: _value_, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }). - 1. Return NormalCompletion(*undefined*). - 1. Let _setter_ be CreateBuiltinFunction(_setterClosure_, 1, "", « »). - 1. Perform ? DefinePropertyOrThrow(_O_, *"stack"*, PropertyDescriptor { [[Get]]: _getter_, [[Set]]: _setter_, [[Enumerable]]: false, [[Configurable]]: true }). + 1. If ? IsExtensible(_O_) is *false*, throw a *TypeError* exception. + 1. Define a new [[ErrorStack]] internal slot on _O_. + 1. Perform ? DefinePropertyOrThrow(_O_, *"stack"*, PropertyDescriptor { [[Get]]: %ErrorCaptureStackTraceGetter%, [[Set]]: %ErrorCaptureStackTraceSetter%, [[Enumerable]]: false, [[Configurable]]: true }). 1. Return *undefined*.
+ +

%ErrorCaptureStackTraceGetter% ( )

+

The value of %ErrorCaptureStackTraceGetter% is a built-in function that takes no arguments. It performs the following steps when called:

+ + 1. Let _O_ be the *this* value. + 1. If _O_ has a [[StackTrace]] internal slot, then + 1. Return _O_.[[StackTrace]]. + 1. Else, + 1. Return *undefined*. + +
+ +

%ErrorCaptureStackTraceSetter% ( _value_ )

+

The value of %ErrorCaptureStackTraceSetter% is a built-in function that takes an argument _value_. It performs the following steps when called:

+ + 1. Perform ? DefinePropertyOrThrow(*this* value, *"stack"*, PropertyDescriptor { [[Value]]: _value_, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }). + 1. Return *undefined*. + +
From bb1f0193f91c27c222b9e07712d279e6a22e41d0 Mon Sep 17 00:00:00 2001 From: Daniel Minor Date: Fri, 24 Oct 2025 14:12:47 -0400 Subject: [PATCH 2/3] Fix [[ErrorStack]]. --- spec.emu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.emu b/spec.emu index eb5b653..235f5d8 100644 --- a/spec.emu +++ b/spec.emu @@ -109,7 +109,7 @@ markEffects: true 1. Else, 1. Assert: _strategy_ is ~accessor~. 1. If ? IsExtensible(_O_) is *false*, throw a *TypeError* exception. - 1. Define a new [[ErrorStack]] internal slot on _O_. + 1. Define a new [[StackTrace]] internal slot on _O_. 1. Perform ? DefinePropertyOrThrow(_O_, *"stack"*, PropertyDescriptor { [[Get]]: %ErrorCaptureStackTraceGetter%, [[Set]]: %ErrorCaptureStackTraceSetter%, [[Enumerable]]: false, [[Configurable]]: true }). 1. Return *undefined*. From 427bb1a2fea98e851081980d28b0a3a6fc871317 Mon Sep 17 00:00:00 2001 From: Daniel Minor Date: Fri, 24 Oct 2025 14:18:09 -0400 Subject: [PATCH 3/3] Make data property non-enumerable --- spec.emu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.emu b/spec.emu index 235f5d8..aa12e62 100644 --- a/spec.emu +++ b/spec.emu @@ -105,7 +105,7 @@ markEffects: true 1. Let _realm_ be the current Realm Record. 1. Let _strategy_ be _realm_.[[ErrorCaptureStackTraceStrategy]]. 1. If _strategy_ is ~data-property~, then - 1. Perform ? DefinePropertyOrThrow(_O_, *"stack"*, PropertyDescriptor { [[Value]]: _string_, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }). + 1. Perform ? DefinePropertyOrThrow(_O_, *"stack"*, PropertyDescriptor { [[Value]]: _string_, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }). 1. Else, 1. Assert: _strategy_ is ~accessor~. 1. If ? IsExtensible(_O_) is *false*, throw a *TypeError* exception.