-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java Compilation fails for this function #863
Comments
What happens if you assign the result of $fn->eval($result.values->evaluateAndDeactivate()) to a variable? Does the generated Java compile once you do the following?
The generated code is 'correct': your Pure code has a statement which does nothing with the result of an expression. Are you expecting the call to |
Thanks @aziemchawdhary-gs. If I make that change as you suggest, I run into the following error: public class test_extension_code
{
public static MutableMap<String, SharedPureFunction<?>> __functions = Maps.mutable.empty();
static
{
__functions.put("meta$nothing$expand$21$system$imports$import__test_extension_code_pure_1$5", new DefaultPureLambdaFunction1<java.lang.Object, org.finos.legend.pure.generated.Root_meta_nothing_Result<? extends T>>()
... (Code does not compile, as the symbol (Other code omitted). I still feel that the code should compile even without that change as, as you suspect, the function has side effects (debug printing). Here is the full PURE code for the record:
|
@aziemchawdhary-gs just pinging you again in case you have any additional insights there. Thanks. |
Tagging @hardikmaheshwari @gs-ssh16 @kevin-m-knight-gs for more visibility. |
@hardikmaheshwari @gs-ssh16 @kevin-m-knight-gs -- any thoughts? |
Hey @gbrgr, I think I agree that ideally, your code should have compiled without changes suggested by @aziemchawdhary-gs, though based on the current state it seems those changes are required. We can discuss more on the correct fix on the platform side In meantime, to get around the issue you facing can you try these changes
You will still need fix suggested by aziem, as errors you see after those are unrelated to one you saw before |
Thank you @hardikmaheshwari. That indeed works for this minimal example. On my side I have a bigger codebase where multiple such errors occur. Is there some documentation available on how the interpreted language differs from the compiled language or is there some other way how to figure out what works in one but not the other? Thanks! |
Hi @gbrgr. There should be no difference between interpreted and compiled modes in terms of compilation (except that compiled mode might take longer as it does more work). If the Pure compiler successfully compiles the Pure code, then the Java generator should generate valid Java code for it. Any discrepancy between the two is a bug. The first case here (the Java compiler complaining that something "is not a statement") is clearly a bug in the Java generator. As @aziemchawdhary-gs noted earlier, there is a relatively easy workaround. Still, the workaround is clumsy and shouldn't be necessary. This is a bug and should be fixed. In the second case, I think that the suggestion that @hardikmaheshwari made is actually a better way to implement that particular function, regardless of Java compilation errors. Nonetheless, if the Pure compiler is compiling the original code, then the Java generator should be generating valid Java code. So, again, I tend to think this is a bug in the Java generator. But unlike the first case, the workaround here is actually a genuine improvement. So I would recommend using Hardik's suggestion in any case. These are two distinct bugs. I believe both bugs are actually in legend-pure rather than legend-engine. I don't think that either will be trivial to fix, but I also don't think either is intractable. |
Thanks @kevin-m-knight-gs for your detailed answer. Unfortunately, I encounter multiple compilation issues when I try to compile our open sourced WIP extension of PURE that integrates our cloud-native knowledge graph management system. The extension code is here: https://github.com/RelationalAI/legend-engine/tree/master/legend-engine-xt-relationalai-pure What is the best way to pin down the exact issues a given PURE code base has? For example, at Java generation, I am just receiving a NullpointerExc. at some point, and it is not really clear to me how to track down that error. Thanks! |
I've created a legend-pure issue for the first bug and committed a fix for the second. The fix was released in legend-pure 3.7.1. A NullPointerException during Java generation is definitely a bug. And that's the kind of bug that can be very difficult to trace back to Pure code. If you have a stack trace you can include here, I'll see what I can figure out from it. |
This issue is stale because it has been open for 30 days with no activity. Please remove stale label or add any comment to keep this open. Otherwise this will be closed in 5 days. |
This issue was closed because it has been inactive for 35 days. Please re-open if this issue is still relevant. |
Bug Report
Steps to Reproduce:
I have the following PURE implementation of a function:
The class
Result
looks as follows:The compiler generates the following Java Code for this function:
However, the compiler complains that the inner statement
"is not a statement".
Environment:
Tested using
legend-engine-3.11.1-SNAPSHOT
andopenjdk 11.0.15 2022-04-19
The text was updated successfully, but these errors were encountered: