-
Notifications
You must be signed in to change notification settings - Fork 77
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
TC: strange import behavior in presence of annotations #496
Comments
The quick summary of the problem is that |
If we want to use a type like that pethaps we should use extend instead of import?— On Wed, Mar 26, 2014 at 3:34 AM, mahills notifications@github.com wrote:
|
An alternative would be to allow re-exporting types and other imported items, this would be more granular versus bringing in everything including private definitions. Right now, from the perspective of the checker, the messages make perfect sense (even though they are wrong) -- the module has never imported a definition of either |
In a way, we already have this re-export feature: Using data X; you can define the existence of X without repeating its In a way any function returning a data type implicitly defines its A wild thought: could we, for every function: X f(...); which uses a declared type X as return type, which is type correct and data X; This way the type remains opaque for those who do not want to see it yet On Wed, Mar 26, 2014 at 12:42 PM, mahills notifications@github.com wrote:
Jurgen Vinju
|
That could be problematic. Even without any other problems, I would have a hard time checking it -- if someone entered To do this, I could just add type names into the type environment if I see them and they haven't been declared yet, but that seems dangerous. This also reveals the other problem -- if |
Hi Mark, I meant it differently. Only if the return type exists and it is correct an abstract declaration is added to the current module for export. Nothing can go wrong then in the importing module. You will get undefined errors only when you start inspecting the contents of rhe type using constructor names their, which makes sense. On Wed, Mar 26, 2014 at 9:15 PM, mahills notifications@github.com wrote:
|
From the perspective of the checker, the problem with this is that I don't know the type is correct -- I don't chase the entire import graph, I just go one level (unless I hit an extends, then I have to do more), so when I'm checking module A, which imports B, I get the signature for B but don't see things that B itself imports. I was marking these types when I found them, though, so maybe I forgot to do that with annotations, I'll have to check. |
Hmm.. maybe we should make this into a Skype session. Perhaps I don't Suppose:
Observations:
So I propose to add to B, implicity:
On Thu, Mar 27, 2014 at 12:52 PM, mahills notifications@github.com wrote:
Jurgen Vinju
|
Skype may be easier, but hopefully I can also just explain better :) Given your scenario, assume I'm checking module A. To do so, I extract the public signature of B, which I need to properly check A. I don't check B when I do this, but assume it is correct. I don't even look at C, since A doesn't import it and B doesn't extend it. I could check B, and/or C, but then, in theory, checking an individual module would involve checking the entire Rascal library. This may be fine, especially if we can cache the information the checker generates so we don't really have to do this every time, but it makes the problem harder and potentially slower, so we don't do it right now. This may be something to talk about :) Carrying on with the example, in this case, as part of this signature import I get the signature for f. If the return type is wrong, I don't have any way of knowing this. So, if I add X as a data type, this may be fine -- I'm just working under the assumption that X is available, since I assume B is correct. It may mask an error, though. It may also be the case that X is really an alias to a type like int, or is a nonterminal, in which case treating it as a data type may not be correct (maybe it doesn't matter -- if the programmer really cared, they would import C). Also, assume we do actually check B. We still may not know that X is correct, since f could be defined as a Java function, and we don't check the implementation of that. |
Ok got it. Another solution is to make all defined types transitively visible, but that again needs typechecking to be incremental. On Thu, Mar 27, 2014 at 3:37 PM, mahills notifications@github.com wrote:
|
This works now. |
I encounter some hard to understand problems with
analysis::m3::AST
.Suspicion: in the handling of annotations the wrong environment is used by the type checker.
Observation 1:
analysis::m3::AST
itself type checks and compiles ok.Observation 2: importing
analysis::m3::AST
in another module is problematic:Attempt A.
gives
Strange, since TypeSymbol is indeed imported in
analysis::m3::AST
, so let's import it ourselves:Attempt B.
gives
Attempt C.
Adding
import Message;
before or afterimport analysis::m3::AST
gives the same message.
The text was updated successfully, but these errors were encountered: