History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: BOO-571
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Rodrigo B. de Oliveira
Reporter: Cameron Kenneth Knight
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Boo

bad op_Member (in/not in) precedence

Created: 30/Oct/05 01:47 PM   Updated: 23/Nov/05 02:54 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 0.7.5

Time Tracking:
Not Specified

Issue Links:
Duplicate
 


 Description  « Hide
>>> if true:
... print 'good'
...
good
>>> if 5 in [1, 2, 3, 4, 5]:
... print 'good'
...
good
>>> if true and 5 in [1, 2, 3, 4, 5]:
... print 'good'
...
good
>>> if 5 in [1, 2, 3, 4, 5] and true:
... print 'good'
...
System.MissingMethodException: Method System.Int32.op_Member not found.
at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
at Boo.Lang.Runtime.RuntimeServices.InvokeBinaryOperator(String operatorName, Object lhs, Object rhs)
at Input6Module.Main(String[] argv)

This happens if you compile with booc as well.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Doug H - 02/Nov/05 09:05 PM
In the conditional_expression rule in boo.g and wsaboo.g, if you change
r=array_or_expression
to
r=sum

it will fix the precedence issue, but then this syntax will not work:

c = 2 in 1,2,3

It gets parsed as:

c = (2 in 1), 2, 3

which generates a compiler error.

c = 2 in (1,2,3)

still works as expected though and does what you want.

So question is should support for this be dropped/made incorrect:

c = 2 in 1,2,3


Cameron Kenneth Knight - 02/Nov/05 09:14 PM
I think that the unclosed array syntax isn't needed outside of multiple declarations.
i, j = 0, 1

As long as this syntax still works, then I don't see why you can't wrap other arrays in parentheses.


Doug H - 02/Nov/05 09:18 PM
Instead of changing it to e=sum I changed it to e=array_or_sum and added a array_or_sum rule (below), and this allows
c = 2 in 1, 2, 3
but not stuff like:
print 6 in true and false, 6, 8

It still seems confusing. I'll leave it to Rodrigo.

protected
array_or_sum returns [Expression e]
{ e = null; ArrayLiteralExpression tle = null; } :
(
// tupla vazia: , ou (,)
c:COMMA { e = new ArrayLiteralExpression(ToLexicalInfo(c)); }
) |
(
e=sum
( options { greedy=true; }:
t:COMMA
{ tle = new ArrayLiteralExpression(e.LexicalInfo); tle.Items.Add(e); }
( options { greedy=true; }:
e=sum { tle.Items.Add(e); }
( options { greedy=true; }:
COMMA
e=sum { tle.Items.Add(e); }
)*
(COMMA)?
)?

{ e = tle; }

)?
)
;


Rodrigo B. de Oliveira - 23/Nov/05 02:54 PM
Parentheses are now required around array literal arguments to 'in'.