- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
aborting, but I want to retry and continue without error
Sat, 2009-12-12, 20:08
First a quick background, I'm trying to run the following phases in a compiler plugin:
earlynamer (as per standard namer, but silent)earlytyper (as per standard typer, but silent) generatesynthetics (generates methods on existing classes)errortyper (redo units that failed early typing)
all between parser and the built-in namer phase.
The idea is that the early namer/typer pair are silenced, to they won't write to the console about methods that haven't yet been synthetically generated.errortyper then goes back of those units that were in error, and attempts to re-process them in the presence of the synthetics.
So I tried this with -Ycheck:earlytyper in the compiler paramsWhat I get back is errors like this:
[consistency check at the beginning of phase treeprinter-earlytyper] [checking Main.scala].\src\main\scala\autoproxy\test\Main.scala:1: error: **** ERROR DURING INTERNAL CHECKING ****package test has wrong owner: package autoproxy, should be: package <root> package autoproxy.test ^
It looks as though typer doesn't even bother trying to leave things in a consistent state if it fails.This would make perfect sense in normal usage where failed typing would abort compilation anyway.
I also tried clearing all types and symbols from the body tree of the affected unit before retyping, via resetAllAttrs(), and even tried taking a snapshot of the tree before the earlytyper that I could then pass to the retyper. Both of these approaches failed because because some symbols are already in symtab.
Question is, does the compiler framework have any mechanisms that could:- help revert the symbols before retyping, or - allow e to retype anyway, overriding the symtab when there's a duplicate (this would probably be the best approach), or- correct the faulty package symbols after earlytyper fails?
Sat, 2009-12-12, 22:17
#2
Re: aborting, but I want to retry and continue without error
On Sat, Dec 12, 2009 at 8:52 PM, martin odersky <martin.odersky@epfl.ch> wrote:
On Sat, Dec 12, 2009 at 8:08 PM, Kevin Wright
<kev.lee.wright@googlemail.com> wrote:
>
> First a quick background, I'm trying to run the following phases in a
> compiler plugin:
> earlynamer (as per standard namer, but silent)
> earlytyper (as per standard typer, but silent)
> generatesynthetics (generates methods on existing classes)
> errortyper (redo units that failed early typing)
> all between parser and the built-in namer phase.
> The idea is that the early namer/typer pair are silenced, to they won't
> write to the console about methods that haven't yet been synthetically
> generated.
> errortyper then goes back of those units that were in error, and attempts to
> re-process them in the presence of the synthetics.
>
>
> So I tried this with -Ycheck:earlytyper in the compiler params
> What I get back is errors like this:
>
> [consistency check at the beginning of phase treeprinter-earlytyper]
> [checking Main.scala]
> .\src\main\scala\autoproxy\test\Main.scala:1: error: **** ERROR DURING
> INTERNAL CHECKING ****
> package test has wrong owner: package autoproxy, should be: package <root>
> package autoproxy.test
> ^
>
> It looks as though typer doesn't even bother trying to leave things in a
> consistent state if it fails.
> This would make perfect sense in normal usage where failed typing would
> abort compilation anyway.
> I also tried clearing all types and symbols from the body tree of the
> affected unit before retyping, via resetAllAttrs(), and even tried taking a
> snapshot of the tree before the earlytyper that I could then pass to the
> retyper.
> Both of these approaches failed because because some symbols are already in
> symtab.
>
> Question is, does the compiler framework have any mechanisms that could:
> - help revert the symbols before retyping, or
Nothing beyond resetAllAttrs, I am afraid.
> - allow e to retype anyway, overriding the symtab when there's a duplicate
> (this would probably be the best approach), or
> - correct the faulty package symbols after earlytyper fails?
I don't think any of this is provided in the current compiler.
Cheers
Sun, 2009-12-13, 12:47
#3
Re: aborting, but I want to retry and continue without error
Don't know if this'll inspire anyone :)But I've now tracked down the issue to singletons, it looks like the moduleClass ends up be inconsistent if typr fails
Traverser for a PackageDef uses `atOwner(tree.symbol.moduleClass)`.That's what TypeChecker uses as the expected owner for a symbol, but it's ending up as <root>
On Sat, Dec 12, 2009 at 9:07 PM, Kevin Wright <kev.lee.wright@googlemail.com> wrote:
On Sat, Dec 12, 2009 at 8:52 PM, martin odersky <martin.odersky@epfl.ch> wrote:
On Sat, Dec 12, 2009 at 8:08 PM, Kevin Wright
<kev.lee.wright@googlemail.com> wrote:
>
> First a quick background, I'm trying to run the following phases in a
> compiler plugin:
> earlynamer (as per standard namer, but silent)
> earlytyper (as per standard typer, but silent)
> generatesynthetics (generates methods on existing classes)
> errortyper (redo units that failed early typing)
> all between parser and the built-in namer phase.
> The idea is that the early namer/typer pair are silenced, to they won't
> write to the console about methods that haven't yet been synthetically
> generated.
> errortyper then goes back of those units that were in error, and attempts to
> re-process them in the presence of the synthetics.
>
>
> So I tried this with -Ycheck:earlytyper in the compiler params
> What I get back is errors like this:
>
> [consistency check at the beginning of phase treeprinter-earlytyper]
> [checking Main.scala]
> .\src\main\scala\autoproxy\test\Main.scala:1: error: **** ERROR DURING
> INTERNAL CHECKING ****
> package test has wrong owner: package autoproxy, should be: package <root>
> package autoproxy.test
> ^
>
> It looks as though typer doesn't even bother trying to leave things in a
> consistent state if it fails.
> This would make perfect sense in normal usage where failed typing would
> abort compilation anyway.
> I also tried clearing all types and symbols from the body tree of the
> affected unit before retyping, via resetAllAttrs(), and even tried taking a
> snapshot of the tree before the earlytyper that I could then pass to the
> retyper.
> Both of these approaches failed because because some symbols are already in
> symtab.
>
> Question is, does the compiler framework have any mechanisms that could:
> - help revert the symbols before retyping, or
Nothing beyond resetAllAttrs, I am afraid.
> - allow e to retype anyway, overriding the symtab when there's a duplicate
> (this would probably be the best approach), or
> - correct the faulty package symbols after earlytyper fails?
I don't think any of this is provided in the current compiler.
Cheers
Sun, 2009-12-13, 13:17
#4
Re: aborting, but I want to retry and continue without error
I think it's hopeless to assume that the typer will recover from all
errors, there are simply too many situations where that could happen.
Probably the best thing one can do is start a new Run in Global. That
will cause roots and other symbols to be updated. The only problem is
that you do not want to re-parse in that situation, so you need to
subclass Global to do that.
Cheers
On Sat, Dec 12, 2009 at 8:08 PM, Kevin Wright
wrote:
>
> First a quick background, I'm trying to run the following phases in a
> compiler plugin:
> earlynamer (as per standard namer, but silent)
> earlytyper (as per standard typer, but silent)
> generatesynthetics (generates methods on existing classes)
> errortyper (redo units that failed early typing)
> all between parser and the built-in namer phase.
> The idea is that the early namer/typer pair are silenced, to they won't
> write to the console about methods that haven't yet been synthetically
> generated.
> errortyper then goes back of those units that were in error, and attempts to
> re-process them in the presence of the synthetics.
>
>
> So I tried this with -Ycheck:earlytyper in the compiler params
> What I get back is errors like this:
>
> [consistency check at the beginning of phase treeprinter-earlytyper]
> [checking Main.scala]
> .\src\main\scala\autoproxy\test\Main.scala:1: error: **** ERROR DURING
> INTERNAL CHECKING ****
> package test has wrong owner: package autoproxy, should be: package
> package autoproxy.test
> ^
>
> It looks as though typer doesn't even bother trying to leave things in a
> consistent state if it fails.
> This would make perfect sense in normal usage where failed typing would
> abort compilation anyway.
> I also tried clearing all types and symbols from the body tree of the
> affected unit before retyping, via resetAllAttrs(), and even tried taking a
> snapshot of the tree before the earlytyper that I could then pass to the
> retyper.
> Both of these approaches failed because because some symbols are already in
> symtab.
>
> Question is, does the compiler framework have any mechanisms that could:
> - help revert the symbols before retyping, or
Nothing beyond resetAllAttrs, I am afraid.
> - allow e to retype anyway, overriding the symtab when there's a duplicate
> (this would probably be the best approach), or
> - correct the faulty package symbols after earlytyper fails?
I don't think any of this is provided in the current compiler.
Cheers