]> gitweb.factorcode.org Git - factor.git/commitdiff
compiler: don't wrap non-inference errors in compile errors, since they indicate...
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 30 Apr 2009 00:39:04 +0000 (19:39 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 30 Apr 2009 00:39:04 +0000 (19:39 -0500)
basis/compiler/compiler.factor
basis/compiler/tests/pic-problem-1.factor [new file with mode: 0644]

index 6783b728e43da8b127dc7d790e1e1bbe4a41492f..cc9899878a298c11f6e51a6e8547dba8343dd577 100644 (file)
@@ -89,21 +89,27 @@ M: predicate-engine-word no-compile? "owner-generic" word-prop no-compile? ;
 : not-compiled-def ( word error -- def )
     '[ _ _ not-compiled ] [ ] like ;
 
+: ignore-error ( word error -- * )
+    drop
+    [ clear-compiler-error ]
+    [ dup def>> deoptimize-with ]
+    bi ;
+
+: remember-error ( word error -- * )
+    [ swap <compiler-error> compiler-error ]
+    [ [ drop ] [ not-compiled-def ] 2bi deoptimize-with ]
+    2bi ;
+
 : deoptimize ( word error -- * )
     #! If the error is ignorable, compile the word with the
     #! non-optimizing compiler, using its definition. Otherwise,
     #! if the compiler error is not ignorable, use a dummy
     #! definition from 'not-compiled-def' which throws an error.
-    2dup ignore-error? [
-        drop
-        [ dup def>> deoptimize-with ]
-        [ clear-compiler-error ]
-        bi
-    ] [
-        [ swap <compiler-error> compiler-error ]
-        [ [ drop ] [ not-compiled-def ] 2bi deoptimize-with ]
-        2bi
-    ] if ;
+    {
+        { [ dup inference-error? not ] [ rethrow ] }
+        { [ 2dup ignore-error? ] [ ignore-error ] }
+        [ remember-error ]
+    } cond ;
 
 : optimize? ( word -- ? )
     {
diff --git a/basis/compiler/tests/pic-problem-1.factor b/basis/compiler/tests/pic-problem-1.factor
new file mode 100644 (file)
index 0000000..4adf0b3
--- /dev/null
@@ -0,0 +1,14 @@
+IN: compiler.tests.pic-problem-1
+USING: kernel sequences prettyprint memory tools.test ;
+
+TUPLE: x ;
+
+M: x length drop 0 ;
+
+INSTANCE: x sequence
+
+<< gc >>
+
+CONSTANT: blah T{ x }
+
+[ T{ x } ] [ blah ] unit-test
\ No newline at end of file