k-legacy icon indicating copy to clipboard operation
k-legacy copied to clipboard

--no-prelude crashes with `java.util.NoSuchElementException: None.get`

Open radumereuta opened this issue 8 years ago • 9 comments

kompile --no-prelude

┆Issue is synchronized with this Asana task

radumereuta avatar Oct 12 '16 13:10 radumereuta

Hello, we tried to recreate this bug but could not. What we did is: kompile --no-prelude --debug k-distribution/tutorial/1_k/2_imp/lesson_4/imp.k. However, we only got an expected error java.lang.AssertionError: While defining module IMP-SYNTAX: Could not find symbol Id as a result of not importing prelude.k . Could you give us more specific instructions on how to reproduce the NoSuchElementException error?

Also, what is the expected result for this test?

Thank you!

HelenRouty avatar Nov 27 '16 20:11 HelenRouty

@radumereuta, you reported this originally. Can you give any more details on reproducing it?

cos avatar Nov 28 '16 00:11 cos

Try it on this:

module TEST
endmodule

Just a simple empty module. Also, I've tested this on windows 10, 64 bits, if that helps.

radumereuta avatar Nov 28 '16 13:11 radumereuta

@radumereuta Thanks to your explanation, I found the same NoSuchElementException error. What should be the expected result when having an empty module? Should we throw an exception or warning or should we simply return a CompiledDefinition with a topCellInitializer of null value?

Currently, after adding three checks, we are able to kompile an empty module with an exit code 0, a warning of no corresponding syntax module, and a CompiledDefinition with KLabel of null value. Is this an expected result? Is there more that should be considered?

Thank you!

HelenRouty avatar Nov 29 '16 03:11 HelenRouty

I'm not sure what should happen. I added this issue because I needed to create a parsing module in which nothing was included automatically. @cos suggested using this option, but I'm not even sure how this would work in the later stages of kompile. What I know for sure is that, in order for the program parser to be clean and correct, I need a way to specify that nothing should be included automatically in that module, because it would taint my grammars with productions or sorts from K. The rest of the modules I don't care.

One possible solution that was discussed at one point was to create a special suffix (-SYNTAX or -PROGRAM-PARSING) that would act as a marker for the automatic inclusion of builtin stuff.

radumereuta avatar Nov 29 '16 12:11 radumereuta

Currently, after adding three checks, we are able to kompile an empty module with an exit code 0, a warning of no corresponding syntax module,

This is good.

and a CompiledDefinition with KLabel of null value.

Which KLabel are you referring to?

cos avatar Dec 01 '16 03:12 cos

The KLabel topCellInitializer in CompiledDefinition

HelenRouty avatar Dec 01 '16 03:12 HelenRouty

what does it say on krun?

cos avatar Dec 01 '16 03:12 cos

We haven't checked with krun. Yeah, there might be problems with krun if we set topCellInitializer to be null. We will probably need to add several more checks.

HelenRouty avatar Dec 01 '16 03:12 HelenRouty