Multi-check entity validate causes compile error
The validate expression in the
Test
entity causes the compiler to crash with the trace below. When removing thet == null
clause or changing the second clause tot.a == this.a
, it builds fine.application testapp entity Test { a : String t : Test2 t3 : Test3 validate (t == null || t.t == this.t3, "error") } entity Test2 { a : String t : Test3 } entity Test3 { a : String } define page root(){ "hi" }
Trace:
Submitted by Elmer van Chastelet on 26 November 2013 at 13:59[ Main | info ] stage 6: performing analysisMain: rewriting failed, trace: webdslc_main_0_0 xtc_io_wrap_5_0 option_wrap_5_0 xtc_io_1_0 xtc_temp_files_1_0 restore_always_2_0 xtc_webdslc_0_0 dsl_to_core_0_0 dsl_to_core_generation_0_0 stage_1_1 dr_scope_1_1 log_timed_1_1 analyze_all_0_0 handle_recursion_0_0 topdown_1_0 try_1_0 add_query_optimization_0_0 add_query_optimization_0_0_fragment_0 foldr_2_0 add_query_optimization_to_argument_0_2 query_analysis_to_query_optimizition_0_4 dr_scope_1_1 dr_scope_1_1 try_1_0 add_filter_anno_to_prefetch_where_0_1 map_1_0 get_filters_for_conditions_0_1 condition_expr_to_filter_condition_1_0 condition_expr_to_filter_condition_1_0 [ Main | critical ] Internal error: with clause failed unexpectedly in rule 'condition-expr-to-filter-condition' (Not(True),[]) BUILD FAILED
Attachments
Issue Log
Chris Gersen commented by email:
The problem
The condition inside the analysis before conversion to an optimization:
!(this.t == null || (this.t != null && this.t.t == this.t3))
To determine the condition for
this
, only direct properties are allowed, and other conditions are removed (meaningthis.t.t == this.t3
).
Normally something that is part of an and-expression can be removed, but not inside a not-expression.
So the following condition is incorrect, yet was the result from attempting to remove part of the condition.!(this.t == null || this.t != null)
After simplification the following condition remains, which could have been further simplified to
false
. As you can see the condition no longer contains a reference tothis
, because of simplification, resulting in errors further down the line. This can be avoided by performing another check on the condition after simplification.!(true)
Changes
src/org/webdsl/dsl/languages/prefetch/condition.str
extract-query-cond
needs to fail when inside a not-expression, instead of returningTrue()
, so that thethis.t.t == this.t3
condition above is not removed from the and-expression.simplify-condition
gets another simplification rule (not required to fix issue):!false -> true, !true -> false
src/org/webdsl/dsl/languages/prefetch/optimization.str
traversal-summary-to-query-condition
needs to revalidate the condition after simplification(attachment changes.zip)
Committed the supplied changes. Thanks Chris :)
Log in to post comments