Unchecked panics
Closed this issue · 0 comments
quasilyte commented
Instead of check+panic it is possible to use symbol
constants to represent
panic sources.
;; Instead of this:
(defconst obj nil)
(if (null obj)
(Go-panic ...))
(aref obj 0))
;; Better to generate this:
(defconst obj nil-struct-ptr)
(aref obj 0)
;; Emacs will generate "wrong-type-argument arrayp nil-struct-ptr" error
Another example.
From spec: Assigning to an element of a nil map causes a run-time panic.
;; Assign special symbol for nil maps
(defconst m 'nil-map)
(puthash 'key 'val m) ;; Causes error "wrong-type-argument hash-table-p nil-map"
I have not found any clues about concrete error messages for run-time panics.
Probably it is conforming behavior to produce different error messages.
Compromise between error clarity and performance should be found.