diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor b/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor index 6401258100..ec73ec3b21 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism-tests.factor @@ -47,6 +47,8 @@ H{ { "a" 1 } { "b" 1 } } [ [ nip ] [ ] if* ] test-poly-infer H{ { "a" 2 } { "b" 2 } } [ [ 3append f ] [ ] if* ] test-poly-infer H{ { "a" 0 } { "b" 0 } } [ [ drop ] [ ] if* ] test-poly-infer +H{ { "a" 0 } { "b" 1 } } [ [ 1 + ] [ "oops" throw ] if* ] test-poly-infer + [ [ write write ] each ] poly-infer-must-fail [ [ ] each ] poly-infer-must-fail [ [ dup ] map ] poly-infer-must-fail @@ -63,9 +65,6 @@ H{ { "a" 0 } { "b" 0 } } [ [ drop ] [ ] if* ] test-poly-infer [ [ ] [ drop ] if* ] poly-infer-must-fail [ [ ] [ 2dup ] if* ] poly-infer-must-fail -[ "derp" each ] poly-infer-must-fail [ each ] poly-infer-must-fail-unknown -[ "derp" [ "derp" ] if ] poly-infer-must-fail -[ [ "derp" ] "derp" if ] poly-infer-must-fail [ [ "derp" ] if ] poly-infer-must-fail-unknown diff --git a/basis/stack-checker/row-polymorphism/row-polymorphism.factor b/basis/stack-checker/row-polymorphism/row-polymorphism.factor index b1acf50551..85d151d478 100644 --- a/basis/stack-checker/row-polymorphism/row-polymorphism.factor +++ b/basis/stack-checker/row-polymorphism/row-polymorphism.factor @@ -55,17 +55,19 @@ M: curried >error-quot [ 2drop ] if ; inline :: (check-input) ( declared actual -- ) - actual declared [ in>> length ] bi@ declared in-var>> - [ check-variable ] keep :> ( in-diff in-var ) - actual declared [ out>> length ] bi@ declared out-var>> - [ check-variable ] keep :> ( out-diff out-var ) - { [ in-var not ] [ out-var not ] [ in-diff out-diff = ] } 0|| - [ - in-var [ in-diff swap adjust-variable ] when* - out-var [ out-diff swap adjust-variable ] when* - ] [ - abandon-check - ] if ; + actual terminated?>> [ + actual declared [ in>> length ] bi@ declared in-var>> + [ check-variable ] keep :> ( in-diff in-var ) + actual declared [ out>> length ] bi@ declared out-var>> + [ check-variable ] keep :> ( out-diff out-var ) + { [ in-var not ] [ out-var not ] [ in-diff out-diff = ] } 0|| + [ + in-var [ in-diff swap adjust-variable ] when* + out-var [ out-diff swap adjust-variable ] when* + ] [ + abandon-check + ] if + ] unless ; : infer-value ( value -- effect ) dup known [ nest-visitor init-inference infer-call* current-effect ] with-scope ; inline @@ -92,9 +94,10 @@ PRIVATE> : check-polymorphic-effect ( word -- ) current-word get [ - dup current-word set stack-effect - dup { [ in-var>> ] [ out-var>> ] } 1|| + dup current-word set + stack-effect dup { [ in-var>> ] [ out-var>> ] } 1|| [ infer-polymorphic-vars ] when drop ] dip current-word set ; SYMBOL: infer-polymorphic? +infer-polymorphic? [ t ] initialize