In TS I have a relation <is: for which I have two custom definitions among some static ones, like this:

relations
	// Custom 1:
    x-ty                        <is:    y-ty
    where x-ty == y-ty
    
    TypeRef("Int", 0, [])       <is:    Integral()
    TypeRef("Float", 0, [])     <is:    FloatingPoint()
    
    // Custom 2:
    ty                          <is: Numeric()
    where ty                    <is: Integral()
       or ty                    <is: FloatingPoint()

If I try to use the second custom relation, the rule always fails:

Add(lhs, _) : TypeRef("Float", 0, [])
where lhs : lhs-ty
  and lhs-ty <is: Numeric()
 else error $[Not numeric!] on lhs

However, if I replace the ty <is: Numeric() custom rule by separate static rules then it works correctly:

relations
    x-ty                        <is:    y-ty
    where x-ty == y-ty
    
    TypeRef("Int", 0, [])       <is:    Integral()
    TypeRef("Float", 0, [])     <is:    FloatingPoint()
    
    // This does work:
    TypeRef("Int", 0, [])       <is:    Numeric()
    TypeRef("Float", 0, [])     <is:    Numeric()

I believe the two approaches should give equivalent results.

Submitted by D. Pelsmaeker on 17 September 2014 at 14:00

On 17 September 2014 at 17:14 D. Pelsmaeker commented:

I found that this issue happens because the two custom relation rules lets TS define two Stratego rules, of which the second is never tried, even when the first custom relation definition should fail during analysis.

This means that this is valid:

Type("Bool")	<is:	Boolean()
Type("Int")		<is:	Integral()

But this is not:

Type("Bool")	<is:	ty
where ty == Boolean()

Type("Int")		<is:	ty
where ty == Integral()

On 19 May 2015 at 22:55 Jeff Smits tagged !jeffsmits

On 12 August 2015 at 14:43 Michael tagged !rolve

Log in to post comments