Typechecking for own custom assignment
Hi,
i created some inline-assignment very similar to NamedTupleComponentReference.
The NamedTupleComponentReference complains about type-missmatches between the value-Expression and the componentDeclaration. Where is that rule defined? I can't find it :-(
Thx,
Mirko
Please sign in to leave a comment.
Hi Mirko,
Most likely it is typeof_NamedTupleLiteral rule.
I've found it by applying 'find node usages' to the 'value' link in NamedTupleComponentReference concept.
Best, Igor.
Hi Igor,
thanks for that. I found that rule too when i was digging around but i didn't realize that this could be the wanted ... for the first look
the second look after your posting tells me, that this one could be the code i was looking for...
but really not easy to understand... javadoc (f.e. for the methods in RulesFunctions_BaseLanguage) or other documentation here would be great!
Everyone who thinks the same is encouraged to vote for the documentation-feature-enhancements in the issue-tracker ;-):
http://youtrack.jetbrains.net/issue/MPS-5949
or
http://youtrack.jetbrains.net/issue/MPS-3178
or
http://youtrack.jetbrains.net/issue/MPS-4921
or others
btw.: can someone tell me, what the thing after ":==:" in "typeof(literal) :==: <(^( literal.tupleDeclaration )^)<*( PTYPES )*>>;" in typeof_NamedTupleLiteral means and does?
Mirko
Hi Mirko,
thanks for feedback, I've asked colleagues to review, especially MPS-4921 (doc on textGen).
Expression
in left part of the type equation constructs instance of NamedTupleType concept using quotation/anti-quotation technique.
here we use quotation < ... > to create the instance:
< ( reference to tuple declaration ) < parameters > >
and reference anti-quotation ^( ... )^ to parameterize reference to tuple declaration
and list anti-quotation *( ... )* to parameterize tuple parameters
see also user guide: http://www.jetbrains.net/confluence/display/MPS/Typesystem#Typesystem-quotations
The alternative would be to write code like:
Regards, Igor.
Hi Mirko,
To find a type rule that caused a certain type error you may use a Go To Rule Which Caused Type Error action in a popup menu shown over a highlighted cell, or rather by pressing ctrl-alt-mouse_left_click on the cell which shows you Type Error dialog, with a button Go To Rule in it.
Regards
Cyril.
Hi Cyril,
pretty cool functionality! This is a feature i was often looking for and actually i wanted to open a new thread on that soon ;-)
The "ctrl-alt-mouse_left_click" works perfect, but i can't get the popup-thing....
Following procedure:
1) write something type-wrong: string a = true;
2) cursor somewhere to the red-underlined "true"
2a) right-click-popup-menu doesn't show "Go To Rule Which Caused Type Error"
2b) "Go To"-Menu doesn't show "Go To Rule Which Caused Type Error"
Full selection of "true" didn't work out too...
i think the point is your "popup menu shown over a highlighted cell" ... the only thing i can find is "Highlight [Usages|Instance]" ... but no "Go To Rule Which Caused Type Error"
so where do i get that popup?
Thanks,
Mirko
Hi Mirko, look into Typesystem submenu, I forgot I should have said that.
Regards, Cyril.