Can you include the hosting code which is evaluating the expression? If I do:
Fooa.cs:
namespace Baz {
public class foo {
public static void Main(string[] args) { }
public static object operator &(foo left, foo right) {
return 42;
}
}
}
import clr
clr.AddReference('fooa')
import Baz
x = Baz.foo()
x & x
this prints 42 (on 2.0 RTM and some random 2.6 build). So either
A.Create(“Test1”) or A.CreateProperty(“Sum”) is not returning a Condition or
there’s something w/ the hosting APIs that’s throwing this off.
I also can’t track down the specific error message – specifically “operator
overloading” doesn’t seem to show up anywhere so I’m a little bit lost what
could be causing it. I would expect something which includes the type names
such as “unsupported operand type(s) for &: 'str' and 'str'”.
From: [email protected]
[mailto:[email protected]] On Behalf Of ??
Sent: Tuesday, May 12, 2009 8:05 PM
To: [email protected]
Subject: [IronPython] unsupported operand type(s) for & operator overloading.
Hi,
I implemented '&' operator overloading in C# class. But When I used
ScriptRuntime compile the expression that use '&' operator, I got a exception
'unsupported operand type(s) for & operator overloading'.
The following is C# code.
public static Group operator &(Condition left, Condition right) {
if (left == null) {
throw new ArgumentNullException("left");
}
if (right == null) {
throw new ArgumentNullException("right");
}
Group re = new Group(left, right, LogicalOperator.And);
return re;
}
IronPython expression like this ' A.Create("Audit") == A.Create("Test1") &
A.CreateProperty("Sum") == A.Create("Test2") '
I tried to convert '&' to 'and'. Although no exception, I lost the left
expression.
Anyone can help me? Thanks.
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com