viatra / EMF-IncQuery

This repository is only kept for historic reasons. All development happens on eclipse.org
http://eclipse.org/viatra
13 stars 4 forks source link

Weird Compiler issues: Parameter 'rDate' has no positive reference in body '#1' #387

Closed tazzme closed 7 years ago

tazzme commented 7 years ago

Hi,

I like your project very much as I have written my doctoral thesis in a close area in the late 2000. I am now working for a large company and I find EMFIncQuery could be very useful in our current project. I achieved creating and executing simple queries with the EMFQueryEngine, but now I'm struggeling with an issue, which could possibly be a bug in the compiler, similar to #77

The following pattern produces a compiler error "Parameter 'rDate' is never referenced in body '#1'"

pattern deploymentOnMember(
                member : java ^iccm.model.EnvironmentMember,
                ipv : java ^iccm.model.InstalledProductVersion,
                rDate : java ^java.util.Date) = {
    EnvironmentMember.installedProductVersions(member, ipv);
    InstalledProductVersion.deploymentDate(ipv, dDate);
    check(rDate > dDate);
    neg find moreRecentVersion(member, ipv, _ipv2);
}

If I add the following lines, I get the compiler error 'Parameter 'rDate' has no positive reference in body '#1''

    java ^java.util.Date(rDate);
    java ^java.util.Date(dDate);

What am I doing wrong?

Thank you. Theresa

ujhelyiz commented 7 years ago

Hi,

thank you for your interest in EMF-IncQuery/VIATRA. We'll be glad if you believe, the project is useful for you.

Looking at the pattern definition, to me it seems the validator is correct in theory (but the error message is quite misleading here). The problem here is that the pattern matcher has to be able to enumerate all possible values for all parameters (which is clearly impossible for java Date values), while in the current case is impossible for the parameter rDate:

In other words, you have to change your pattern to be expressible in EMF-IncQuery/VIATRA: basically, the value of rDate has to be deterministically calculable from elements you find in the model. E.g. you can express rDate is 10 days later that the deploymentDate; or you can compare two date values stored in the model, but cannot express all dates that are after some date found in the model.

I hope this explanation was clear; if not feel free to ask for clarification.


In addition to answering your question, I have two points to clarify here:

  1. Looking at the issue text it was not clear to me whether you are using EMF-IncQuery or VIATRA. You mention EMF-IncQuery explicitly, but your query example includes features only present in the latest VIATRA release. This February EMF-IncQuery was merged into VIATRA (see corresponding blog post for details). We are glad to help to various issues, but it would help us to clarify which version you are using.
  2. VIATRA is an open source project at eclipse.org, and we manage public forums and bug tracker there (list of open bugs, enter new bug here). It would also help us if questions or bug reports are collected there.

Finally, I have opened a new issue to make the error messages easier to understand (and possibly see whether there is some kind of issue with incorrect reporting as well).

tazzme commented 7 years ago

Fine, thank you for your fast response and the good explanation. I was not aware of the fact, that check-expressions must be deterministically calculable. So I solved this with rewriting the query. Thank you.