]> gitweb.factorcode.org Git - factor.git/blob - core/inference/errors/errors.factor
Fixing everything for mandatory stack effects
[factor.git] / core / inference / errors / errors.factor
1 ! Copyright (C) 2006, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 IN: inference.errors
4 USING: inference.backend inference.dataflow kernel generic
5 sequences prettyprint io words arrays inspector effects debugger
6 assocs accessors ;
7
8 M: inference-error error-help error>> error-help ;
9
10 M: inference-error error.
11     dup rstate>>
12     keys [ dup value? [ value-literal ] when ] map
13     dup empty? [ "Word: " write dup peek . ] unless
14     swap error>> error. "Nesting: " write . ;
15
16 M: unbalanced-branches-error error.
17     "Unbalanced branches:" print
18     [ quots>> ] [ in>> ] [ out>> [ length ] map ] tri 3array flip
19     [ [ bl ] [ pprint ] interleave nl ] each ;
20
21 M: literal-expected summary
22     drop "Literal value expected" ;
23
24 M: too-many->r summary
25     drop
26     "Quotation pushes elements on retain stack without popping them" ;
27
28 M: too-many-r> summary
29     drop
30     "Quotation pops retain stack elements which it did not push" ;
31
32 M: cannot-infer-effect error.
33     "Unable to infer stack effect of " write word>> . ;
34
35 M: missing-effect error.
36     "The word " write
37     word>> pprint
38     " must declare a stack effect" print ;
39
40 M: effect-error error.
41     "Stack effects of the word " write
42     [ word>> pprint " do not match." print ]
43     [ "Inferred: " write inferred>> effect>string . ]
44     [ "Declared: " write declared>> effect>string . ] tri ;
45
46 M: recursive-quotation-error error.
47     "The quotation " write
48     quot>> pprint
49     " calls itself." print
50     "Stack effect inference is undecidable when quotation-level recursion is permitted." print ;
51
52 M: cannot-unify-specials summary
53     drop
54     "Cannot unify branches with inconsistent special values" ;