bugfix: unbound variables were not raising error
Since we switched error trace semantics from a designated label to a designated
depth (commit 9831a8cef9
on May 19).
This commit is contained in:
parent
961ce67569
commit
067fa9c725
|
@ -49,7 +49,7 @@ highlight link muError Error
|
|||
" sources of action at a distance
|
||||
syntax match muAssign "<-"
|
||||
highlight link muAssign SpecialChar
|
||||
syntax keyword muAssign error
|
||||
syntax keyword muAssign error error-stream
|
||||
highlight link muAssign Special
|
||||
|
||||
" common keywords
|
||||
|
|
|
@ -819,7 +819,7 @@ fn lookup-symbol sym: (addr cell), out: (addr handle cell), env-h: (handle cell)
|
|||
trace-lower trace
|
||||
var _env/eax: (addr cell) <- lookup env-h
|
||||
var env/ebx: (addr cell) <- copy _env
|
||||
# if env is not a list, abort
|
||||
# if env is not a list, error
|
||||
{
|
||||
var env-type/ecx: (addr int) <- get env, type
|
||||
compare *env-type, 0/pair
|
||||
|
|
|
@ -395,7 +395,7 @@ fn lookup-symbol-in-globals _sym: (addr cell), out: (addr handle cell), _globals
|
|||
write stream, "unbound symbol: "
|
||||
rewind-stream sym-name
|
||||
write-stream stream, sym-name
|
||||
trace trace, "error", stream
|
||||
error-stream trace, stream
|
||||
}
|
||||
|
||||
fn maybe-lookup-symbol-in-globals _sym: (addr cell), out: (addr handle cell), _globals: (addr global-table), trace: (addr trace) {
|
||||
|
@ -506,7 +506,7 @@ fn mutate-binding-in-globals name: (addr stream byte), val: (addr handle cell),
|
|||
write stream, "unbound symbol: "
|
||||
rewind-stream name
|
||||
write-stream stream, name
|
||||
trace trace, "error", stream
|
||||
error-stream trace, stream
|
||||
}
|
||||
|
||||
# a little strange; goes from value to name and selects primitive based on name
|
||||
|
|
|
@ -192,7 +192,7 @@ fn parse-sexpression tokens: (addr stream cell), _out: (addr handle cell), trace
|
|||
var curr-token-data/eax: (addr stream byte) <- lookup *curr-token-data-ah
|
||||
rewind-stream curr-token-data
|
||||
write-stream stream, curr-token-data
|
||||
trace trace, "error", stream
|
||||
error-stream trace, stream
|
||||
}
|
||||
trace-higher trace
|
||||
return 0/false, 0/false
|
||||
|
|
|
@ -721,8 +721,26 @@ fn test-run-error-invalid-integer {
|
|||
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
|
||||
# skip one line of padding
|
||||
check-screen-row screen, 1/y, " 1a ", "F - test-run-error-invalid-integer/0"
|
||||
check-screen-row screen, 2/y, " ... ", "F - test-run-error-invalid-integer/0"
|
||||
check-screen-row screen, 3/y, " invalid number ", "F - test-run-error-invalid-integer/2"
|
||||
check-screen-row screen, 2/y, " ... ", "F - test-run-error-invalid-integer/1"
|
||||
check-screen-row-in-color screen, 0xc/fg=error, 3/y, " invalid number ", "F - test-run-error-invalid-integer/2"
|
||||
}
|
||||
|
||||
fn test-run-error-unknown-symbol {
|
||||
var sandbox-storage: sandbox
|
||||
var sandbox/esi: (addr sandbox) <- address sandbox-storage
|
||||
initialize-sandbox-with sandbox, "a"
|
||||
# eval
|
||||
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/no-screen, 0/no-tweak-screen
|
||||
# setup: screen
|
||||
var screen-on-stack: screen
|
||||
var screen/edi: (addr screen) <- address screen-on-stack
|
||||
initialize-screen screen, 0x80/width, 0x10/height, 0/no-pixel-graphics
|
||||
#
|
||||
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
|
||||
# skip one line of padding
|
||||
check-screen-row screen, 1/y, " a ", "F - test-run-error-unknown-symbol/0"
|
||||
check-screen-row screen, 2/y, " ... ", "F - test-run-error-unknown-symbol/1"
|
||||
check-screen-row-in-color screen, 0xc/fg=error, 3/y, " unbound symbol: a ", "F - test-run-error-unknown-symbol/2"
|
||||
}
|
||||
|
||||
fn test-run-with-spaces {
|
||||
|
|
|
@ -195,6 +195,20 @@ fn error _self: (addr trace), message: (addr array byte) {
|
|||
copy-to *curr-depth-a, save-depth
|
||||
}
|
||||
|
||||
fn error-stream _self: (addr trace), message: (addr stream byte) {
|
||||
var self/esi: (addr trace) <- copy _self
|
||||
compare self, 0
|
||||
{
|
||||
break-if-!=
|
||||
abort "null trace"
|
||||
}
|
||||
var curr-depth-a/eax: (addr int) <- get self, curr-depth
|
||||
var save-depth/ecx: int <- copy *curr-depth-a
|
||||
copy-to *curr-depth-a, 0/error
|
||||
trace self, "error", message
|
||||
copy-to *curr-depth-a, save-depth
|
||||
}
|
||||
|
||||
fn initialize-trace-line depth: int, label: (addr array byte), data: (addr stream byte), _out: (addr trace-line) {
|
||||
var out/edi: (addr trace-line) <- copy _out
|
||||
# depth
|
||||
|
|
Loading…
Reference in New Issue
Block a user