Skip to content
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,35 @@ markEffects: true
<p></p>
</emu-intro>

<emu-clause id="sec-agents">
<h1>Agents</h1>

<emu-table id="table-agent-record" caption="Agent Record Fields">
<table>
<thead>
<tr>
<th>Field Name</th>
<th>Value</th>
<th>Meaning</th>
</tr>
</thead>
<tr>
<td>[[UseErrorCaptureStackTraceDataProperty]]</td>
<td>a Boolean</td>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: since this isn't a yes/no, it's an either/or, we would typically use a 2-state enum for this. Something like [[ErrorCaptureStackTraceStrategy]] with type "~data-property~ or ~accessor~".

<td>Whether to use a data property or an accessor property for the "stack" property installed by Error.captureStackTrace.</td>
</tr>
</table>
</emu-table>

<p>Once the values of [[Signifier]], [[IsLockFree1]], [[IsLockFree2]], and [[UseErrorCaptureStackTraceDataProperty]] have been observed by any agent in the agent cluster they cannot change.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<p>Once the values of [[Signifier]], [[IsLockFree1]], [[IsLockFree2]], and [[UseErrorCaptureStackTraceDataProperty]] have been observed by any agent in the agent cluster they cannot change.</p>
<p>Once the values of [[Signifier]], [[IsLockFree1]], [[IsLockFree2]], and [[ErrorCaptureStackTraceStrategy]] have been observed by any agent in the agent cluster they cannot change.</p>

Need to update this field name here and below.

</emu-clause>

<emu-clause id="sec-agent-clusters">
<h1>Agent Clusters</h1>

<p>All agents within a cluster must have the same value for the [[UseErrorCaptureStackTraceDataProperty]] field in their respective Agent Records.</p>
</emu-clause>

<emu-clause id="sec-fundamental-objects" number="20">
<h1>Fundamental Objects</h1>

Expand All @@ -34,7 +63,18 @@ markEffects: true
1. NOTE: This can be used to hide implementation details on the stack trace that aren't useful to user.
1. Else,
1. Let _string_ be an implementation-defined string that represents the current stack trace.
1. Perform ? SetterThatIgnoresPrototypeProperties(_error_, OrdinaryObjectCreate(*null*), *"stack"*, _string_).
1. Let _useErrorCaptureStackTraceDataProperty_ be the value of the [[UseErrorCaptureStackTraceDataProperty]] field of the surrounding agent's Agent Record.
1. If _useErrorCaptureStackTraceDataProperty_ is *true*, then
1. Perform ? SetterThatIgnoresPrototypeProperties(_error_, OrdinaryObjectCreate(*null*), *"stack"*, _string_)..
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To bring the two cases closer together it would be nice if both cases go through the same definition primitive. E.g., we could have an implementation specific PropertyDescriptor ([[Get]] vs. [[Value]]) which is then installed in the same way (e.g., OrdinaryDefineOwnProperty) in both cases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer all of the things that share the behaviour described in SetterThatIgnoresPrototypeProperties go through that AO. It's a very specific exception to how we usually do things in the language and it should both have fully consistent normative requirements and be discoverable. Reusing that AO helps with both goals.

1. Else,
1. If ? IsExtensible( _error_ ) is *false*, throw a *TypeError* exception.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting nit:

Suggested change
1. If ? IsExtensible( _error_ ) is *false*, throw a *TypeError* exception.
1. If ? IsExtensible(_error_) is *false*, throw a *TypeError* exception.

1. Let getterClosure be a new Abstract Closure with no parameters that captures _string_ and performs the following steps when called:
Copy link
Member

@michaelficarra michaelficarra Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Let getterClosure be a new Abstract Closure with no parameters that captures _string_ and performs the following steps when called:
1. Let _getterClosure_ be a new Abstract Closure with no parameters that captures _string_ and performs the following steps when called:

Similarly for all the bindings below.

1. Return NormalCompletion(_string_).
1. Let getter be CreateBuiltinFunction(getterClosure, 0, "", « »).
1. Let setterClosure be a new Abstract Closure with parameters (_value_) that captures _error_ and performs the following steps when called:
1. Perform ! SetterThatIgnoresPrototypeProperties(_error_, OrdinaryObjectCreate(*null*), *"stack"*, _value_).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Perform ! SetterThatIgnoresPrototypeProperties(_error_, OrdinaryObjectCreate(*null*), *"stack"*, _value_).
1. Perform ? SetterThatIgnoresPrototypeProperties(_error_, OrdinaryObjectCreate(*null*), *"stack"*, _value_).

This AO can fail if the setter is called after the "stack" property is deleted, for example.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Perform ! SetterThatIgnoresPrototypeProperties(_error_, OrdinaryObjectCreate(*null*), *"stack"*, _value_).
1. Perform ! SetterThatIgnoresPrototypeProperties(_error_, *null*, *"stack"*, _value_).

This is just used for a SameValue test against _error_, so you just need to pass anything else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You still need to return something here.

Suggested change
1. Perform ! SetterThatIgnoresPrototypeProperties(_error_, OrdinaryObjectCreate(*null*), *"stack"*, _value_).
1. Perform ! SetterThatIgnoresPrototypeProperties(_error_, OrdinaryObjectCreate(*null*), *"stack"*, _value_).
2. Return NormalCompletion(*undefined*).

1. Let setter be CreateBuiltinFunction(setterClosure, 1, "", « »).
1. Perform ! OrdinaryDefineOwnProperty(_error_, *"stack"*, PropertyDescriptor { [[Get]]: getter, [[Set]]: setter, [[Enumerable]]: false, [[Configurable]]: true }).
1. Return *undefined*.
</emu-alg>
</emu-clause>
Expand Down