Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Compiler
-
Labels:None
-
Number of attachments :
Description
A lot of types in the BCL (System.Decimal for instance) define implicit and explict conversion operators [1].
Those operators should be used by boo as apropriate for assignments, function argument evaluation (including overloaded operators) and cast expressions.
More explicitly, the following boo program:
def x2(value as Decimal):
return value*2
print(x2(4))
d as Decimal = 0
should be interpreted as:
def x2(value as Decimal):
return Decimal.op_Multiply(value, Decimal.op_Implicit(2))
print(x2(Decimal.op_Implicit(4)))
d as Decimal = Decimal.op_Implicit(0)
Issue Links
Activity
Rodrigo B. de Oliveira
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Fix Version/s | 0.4 [ 10961 ] |
Rodrigo B. de Oliveira
made changes -
| Fix Version/s | 0.4 [ 10961 ] | |
| Fix Version/s | 0.5 [ 10963 ] |
Rodrigo B. de Oliveira
made changes -
| Fix Version/s | 0.5 [ 10963 ] | |
| Fix Version/s | 0.6 [ 11022 ] |
Rodrigo B. de Oliveira
made changes -
Doug H
made changes -
| Attachment | opimplicit1.patch [ 17296 ] |
Rodrigo B. de Oliveira
made changes -
| Fix Version/s | 0.7.5 [ 12052 ] | |
| Fix Version/s | 0.7.6 [ 12110 ] |
Doug H
made changes -
| Comment |
[ I changed ProcessMethodBodies.FindConversionOperator to the below code. A test is below that. IMethod FindConversionOperator(string name, IType fromType, IType toType) { IType origType = fromType; while (fromType != TypeSystemServices.ObjectType) { foreach (IEntity entity in fromType.GetMembers()) { if (EntityType.Method == entity.EntityType && name == entity.Name) { IMethod method = (IMethod)entity; if (IsConversionOperator(method, fromType, toType)) { return method; } } } fromType = fromType.BaseType; if (null == fromType) break; } fromType = origType; origType = toType; while (toType != TypeSystemServices.ObjectType) { foreach (IEntity entity in toType.GetMembers()) { if (EntityType.Method == entity.EntityType && name == entity.Name) { IMethod method = (IMethod)entity; if (IsConversionOperator(method, fromType, toType)) { return method; } } } toType = toType.BaseType; if (null == toType) break; } return null; } ////////////////////////////////////////////////////////////////////// import System import System.Runtime.InteropServices obj = object() //succeeds: ptr as IntPtr = cast(IntPtr, GCHandle.Alloc( obj )) //previously failed: gch = cast(GCHandle, ptr) //should fail because op_Explicit requires explicit cast: //gch2 as GCHandle = ptr print gch ] |
Doug H
made changes -
| Attachment | opimplicit5.patch [ 19248 ] |
Doug H
made changes -
| Attachment | opimplicit5.patch [ 19248 ] |
Doug H
made changes -
| Attachment | opimplicit6.patch [ 19257 ] |
Doug H
made changes -
| Attachment | opimplicit6.patch [ 19257 ] |
Doug H
made changes -
| Attachment | opimplicit7.patch [ 19258 ] |
Doug H
made changes -
| Attachment | opimplicit7.patch [ 19258 ] |
Doug H
made changes -
| Fix Version/s | 0.7.6 [ 12110 ] | |
| Resolution | Won't Fix [ 2 ] | |
| Status | Open [ 1 ] | Closed [ 6 ] |