compiler: don't wrap non-inference errors in compile errors, since they indicate compiler bugs; just rethrow them. Add unit test for a PIC regression
parent
38a38a57a9
commit
deaea55d85
|
@ -89,21 +89,27 @@ M: predicate-engine-word no-compile? "owner-generic" word-prop no-compile? ;
|
||||||
: not-compiled-def ( word error -- def )
|
: not-compiled-def ( word error -- def )
|
||||||
'[ _ _ not-compiled ] [ ] like ;
|
'[ _ _ 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 -- * )
|
: deoptimize ( word error -- * )
|
||||||
#! If the error is ignorable, compile the word with the
|
#! If the error is ignorable, compile the word with the
|
||||||
#! non-optimizing compiler, using its definition. Otherwise,
|
#! non-optimizing compiler, using its definition. Otherwise,
|
||||||
#! if the compiler error is not ignorable, use a dummy
|
#! if the compiler error is not ignorable, use a dummy
|
||||||
#! definition from 'not-compiled-def' which throws an error.
|
#! definition from 'not-compiled-def' which throws an error.
|
||||||
2dup ignore-error? [
|
{
|
||||||
drop
|
{ [ dup inference-error? not ] [ rethrow ] }
|
||||||
[ dup def>> deoptimize-with ]
|
{ [ 2dup ignore-error? ] [ ignore-error ] }
|
||||||
[ clear-compiler-error ]
|
[ remember-error ]
|
||||||
bi
|
} cond ;
|
||||||
] [
|
|
||||||
[ swap <compiler-error> compiler-error ]
|
|
||||||
[ [ drop ] [ not-compiled-def ] 2bi deoptimize-with ]
|
|
||||||
2bi
|
|
||||||
] if ;
|
|
||||||
|
|
||||||
: optimize? ( word -- ? )
|
: optimize? ( word -- ? )
|
||||||
{
|
{
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue