factor/basis/inference/errors/errors.factor

55 lines
1.6 KiB
Factor
Raw Normal View History

2008-04-04 01:33:06 -04:00
! Copyright (C) 2006, 2008 Slava Pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
2008-07-12 23:27:28 -04:00
USING: kernel generic sequences prettyprint io words arrays
summary effects debugger assocs accessors inference.backend
inference.dataflow ;
2007-09-20 18:09:08 -04:00
IN: inference.errors
M: inference-error error-help error>> error-help ;
2007-09-20 18:09:08 -04:00
M: inference-error error.
2008-04-04 01:33:06 -04:00
dup rstate>>
2007-09-20 18:09:08 -04:00
keys [ dup value? [ value-literal ] when ] map
dup empty? [ "Word: " write dup peek . ] unless
2008-04-04 01:33:06 -04:00
swap error>> error. "Nesting: " write . ;
2007-09-20 18:09:08 -04:00
M: unbalanced-branches-error error.
"Unbalanced branches:" print
[ quots>> ] [ in>> ] [ out>> [ length ] map ] tri 3array flip
[ [ bl ] [ pprint ] interleave nl ] each ;
2007-09-20 18:09:08 -04:00
M: literal-expected summary
drop "Literal value expected" ;
M: too-many->r summary
drop
"Quotation pushes elements on retain stack without popping them" ;
M: too-many-r> summary
drop
"Quotation pops retain stack elements which it did not push" ;
2008-06-08 16:32:55 -04:00
M: cannot-infer-effect error.
"Unable to infer stack effect of " write word>> . ;
2007-09-20 18:09:08 -04:00
2008-06-08 16:32:55 -04:00
M: missing-effect error.
"The word " write
word>> pprint
2007-09-20 18:09:08 -04:00
" must declare a stack effect" print ;
M: effect-error error.
"Stack effects of the word " write
2008-06-08 16:32:55 -04:00
[ word>> pprint " do not match." print ]
[ "Inferred: " write inferred>> effect>string . ]
[ "Declared: " write declared>> effect>string . ] tri ;
2007-09-20 18:09:08 -04:00
M: recursive-quotation-error error.
"The quotation " write
quot>> pprint
2007-09-20 18:09:08 -04:00
" calls itself." print
"Stack effect inference is undecidable when quotation-level recursion is permitted." print ;
M: cannot-unify-specials summary
drop
"Cannot unify branches with inconsistent special values" ;