aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-08-07 15:50:58 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-08-07 15:50:58 -0700
commit345cdfb7b9ba7eec98f0378530cd05074999877b (patch)
treeedd38d86f0ea1714a0f78c42af044bcdd53e7781 /lib
parentAdd booleans. (diff)
downloadchromatopelma-345cdfb7b9ba7eec98f0378530cd05074999877b.tar.zst
Fix a bug in the records library.
We have to check if it's a pointer before dereferencing.
Diffstat (limited to 'lib')
-rw-r--r--lib/scheme/base/50-records.csc3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/scheme/base/50-records.csc b/lib/scheme/base/50-records.csc
index 2830b3c..e0954d3 100644
--- a/lib/scheme/base/50-records.csc
+++ b/lib/scheme/base/50-records.csc
@@ -80,7 +80,8 @@
(let ((id *next-type-id*))
(set! *next-type-id* (call-builtin + 1 *next-type-id*))))
(define (pred r)
- (call-builtin eq? type-id (call-builtin peek r 0)))
+ (and (call-builtin eq? 0 (call-builtin typeof r))
+ (call-builtin eq? type-id (call-builtin peek r 0))))
(define (constructor field ...)
(define r (call-builtin alloc (macro-length (field ...))))
(call-builtin poke type-id r 0)