unbalanced-branches-error ( word quots declareds actuals -- * )
Factor handbook » The language » Stack effect checking » Stack checker errors

Prev:effect-error ( inferred declared -- * )
Next:undeclared-recursion-error ( word -- * )


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


Methods

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. ;



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 ;