The validate expression in the Test entity causes the compiler to crash with the trace below. When removing the t == null clause or changing the second clause to t.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:

[ 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
Submitted by Elmer van Chastelet on 26 November 2013 at 13:59
changes.zip6 January 2014 at 11:49

On 28 November 2013 at 12:30 Elmer van Chastelet tagged validation

On 17 December 2013 at 14:29 Elmer van Chastelet tagged query-optimization

On 6 January 2014 at 11:49 Danny Groenewegen commented:

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 (meaning this.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 to this, 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 returning True(), so that the this.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)


On 8 January 2014 at 12:26 Elmer van Chastelet commented:

Committed the supplied changes. Thanks Chris :)


On 8 January 2014 at 12:26 Elmer van Chastelet closed this issue.

Log in to post comments