@@ -71,7 +71,13 @@ import { HostFunction, HostNamespace } from "./host.js"
7171import { invokeIntrinsic } from "./methods.js"
7272import { preserveConsumerError , type Runner } from "./runner.js"
7373import { invokePromiseInstanceMethod , PromiseRuntime , resolvePromise , resolvePromiseValue } from "./promises.js"
74- import { containsOpaqueReference , isRuntimeReference , rejectCircularInsertion , typeofValue } from "./references.js"
74+ import {
75+ containsOpaqueReference ,
76+ describeValue ,
77+ isRuntimeReference ,
78+ rejectCircularInsertion ,
79+ typeofValue ,
80+ } from "./references.js"
7581import { ScopeStack } from "./scope.js"
7682import { arrayMethods , mapMethods , setMethods } from "../stdlib/collections.js"
7783import { dateMethods } from "../stdlib/date.js"
@@ -1025,7 +1031,7 @@ class Frame<R> {
10251031 if ( pattern . type === "ObjectPattern" ) {
10261032 if ( value === null || typeof value !== "object" || isRuntimeReference ( value ) ) {
10271033 throw new InterpreterRuntimeError (
1028- " Object destructuring requires a data object or array value." ,
1034+ ` Object destructuring requires a data object or array value, received ${ describeValue ( value ) } .` ,
10291035 pattern ,
10301036 "InvalidDataValue" ,
10311037 )
@@ -1091,7 +1097,7 @@ class Frame<R> {
10911097 if ( pattern . type === "ObjectPattern" ) {
10921098 if ( value === null || typeof value !== "object" || isRuntimeReference ( value ) ) {
10931099 throw new InterpreterRuntimeError (
1094- " Object destructuring requires a data object or array value." ,
1100+ ` Object destructuring requires a data object or array value, received ${ describeValue ( value ) } .` ,
10951101 pattern ,
10961102 "InvalidDataValue" ,
10971103 )
@@ -1896,7 +1902,11 @@ class Frame<R> {
18961902 const spread = yield * self . evaluateExpression ( property . argument )
18971903 if ( spread === null || spread === undefined || Values . isValue ( spread ) ) continue
18981904 if ( typeof spread !== "object" || Array . isArray ( spread ) || isRuntimeReference ( spread ) ) {
1899- throw new InterpreterRuntimeError ( "Object spread requires a data object." , property , "InvalidDataValue" )
1905+ throw new InterpreterRuntimeError (
1906+ `Object spread requires a data object, received ${ describeValue ( spread ) } .` ,
1907+ property ,
1908+ "InvalidDataValue" ,
1909+ )
19001910 }
19011911 for ( const [ key , value ] of Object . entries ( spread ) ) {
19021912 if ( isBlockedMember ( key ) ) throw new InterpreterRuntimeError ( `Property '${ key } ' is not available.` , property )
@@ -2126,7 +2136,7 @@ class Frame<R> {
21262136
21272137 if ( isRuntimeReference ( objectValue ) ) {
21282138 throw new InterpreterRuntimeError (
2129- "Runtime references are opaque and do not expose properties." ,
2139+ `Cannot read properties of ${ describeValue ( objectValue ) } ; only data values expose properties.` ,
21302140 objectNode ,
21312141 "InvalidDataValue" ,
21322142 )
0 commit comments