unbalanced-branches-error ( word quots declareds actuals -- * ) (original) (raw)
Vocabulary
stack-checker.errors
Error description
Thrown when inference encounters an inline combinator whose input quotations do not match their declared effects, or when it encounters an if or dispatch whose branches do not all exit with the same stack height. See Combinator stack effects and Branch stack effects for details.
Examples
: if-unbalanced-branches-example ( a b c -- ) [ + ] [ dup ] if ;
: each-unbalanced-branches-example ( x seq -- x' ) [ 3append ] each ;
Definition
ERROR: unbalanced-branches-error < inference-error
word quots declareds actuals ;
Methods
USING: accessors arrays debugger io kernel prettyprint sequences
stack-checker.errors summary ;
M: unbalanced-branches-error error.
dup summary print nl "For more information, evaluate:" print
" \"inference-branches\" help" print nl
[ quots>> ] [ declareds>> ] [ actuals>> ] tri 3array flip
{ "Input" "Expected" "Got" } prefix simple-table. ;
USING: accessors kernel sequences stack-checker.errors summary ;
M: unbalanced-branches-error summary
[ word>> name>> ] [ quots>> length 1 = ] bi [
"The input quotation to '"
"' doesn't match its expected effect"
] [
"The input quotations to '"
"' do not all leave the stack at the same height"
] if surround ;