Ticket #232 (new defect)
Small inconsistency in 'if a inherits B' semantics.
Reported by: | nevdelap | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | Cobra Compiler | Version: | 0.8.0 |
Keywords: | Cc: |
Description
Once the 'a inherits B' is found to be true and a is allowed to be used as a B it would be nice if it was allowed in subsequent parts of the same expression rather than needing to wait until the next statement.
The second and third if statements here are the example.
In other words 'if x, if y, do something' should be equivalent to 'if x and y, do something'.
I hope I'm being clear enough.
class A pass class B inherits A pass class P var _list as List<of B> is shared def main is shared a as A = B() #_list.add(a) No allowed, ok. if a inherits B _list.add(a) # Magically allowed by Cobra. if a inherits B if not _list.contains(a) # Ditto. _list.add(a) if a inherits B and not _list.contains(a) # error _list.add(a)
error: Argument 1 of method "contains" expects type B?, but the call is supplying type A.
Change History
Note: See
TracTickets for help on using
tickets.