ceylon / ceylon-compiler

DEPRECATED
GNU General Public License v2.0
138 stars 36 forks source link

Error in argument on command line gets turned into a compiler error #1179

Closed quintesse closed 11 years ago

quintesse commented 11 years ago

when I type something like "ceylon compile mymodule 3", where "3" is just a number I typed by accident I get:

ceylon compile: invalid flag: 2 Usage: ceylon compile use --help for a list of possible options ceylon compile: Fatal error: The compiler exited abnormally (2) due to a bug in the compiler. Please report it: https://github.com/ceylon/ceylon-compiler/issues/new Please include:

etc etc

tombentley commented 11 years ago

Investigating this it turns out that there are a few other situations where we are treating javac's EXIT_CMDERR (i.e. bad command line options, only in our case they're the options passed from CeylonCompileTool) as a bug. My reasoning for classifying this as a bug was that CeylonCompileTool should be formatting the arguments it passes to Main.compile() correctly in all cases. Most of those cases are easily fixed by putting suitable checking of options in CeylonCompileTool (we can actually reuse the same code that Main uses, so the only real downside to doing this is the runtime cost of having some options checked twice, once by CeylonCompileTool and once by Main).

How we're handling the module-name-or-source-file argument is currently a miserable kludge. For example:

quintesse commented 11 years ago

or we should only ever look for source files contained in --src directories, and ignore source files in the cwd

Stef will remove your balls with an escargot fork if you do that :)

FroMage commented 11 years ago

Source files relative to the cwd take precedence over same named source files in the source (or other --src) directory. I think it should be the other way around, or we should only ever look for source files contained in --src directories, and ignore source files in the cwd.

User-specified source files are ALWAYS relative to cwd, never to source dirs. Otherwise there's no completion possible. As far as I know, ATM we don't resolve files relative to source dirs, we only use those for compilation of specified modules, and for looking up the package names from the specified files.

If there are two source directories each containing a source file with the same name relative to its containing source directory, the first one wins. I think we should either detect + reject this case (e.g. it will lead to confusing stacktraces), or we should compile both source files.

This is actually a feature when the user specifies specific files, because you may want to have multiple versions of the same file in different source folder and only compile the ones you pick.

Now, we could detect this in the case of specifying modules, because then the files are auto-scanned, but this is very cosmetic ATM and can wait in another issue until the more urgent stuff is done.

tombentley commented 11 years ago

Fixed