Skip to content

Commit 14ab088

Browse files
committed
Add error when reading invalid reference
Previously it would just return undefined which would throw an error when attempting to use the object later on. Now you’re able to demangle the stack trace to find exactly where you’re misusing a ref.
1 parent 74610c2 commit 14ab088

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Runtime/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ class SwiftRuntimeHeap {
119119
}
120120

121121
referenceHeap(ref: ref) {
122-
return this._heapValueById.get(ref)
122+
const value = this._heapValueById.get(ref)
123+
if (value === undefined) {
124+
throw new ReferenceError("Attempted to read invalid reference " + ref)
125+
}
126+
return value
123127
}
124128
}
125129

0 commit comments

Comments
 (0)