Quellcode durchsuchen

Cast numeric to Var type on assignment. Fixes #54.

woollybah vor 10 Jahren
Ursprung
Commit
43916da8de
1 geänderte Dateien mit 7 neuen und 1 gelöschten Zeilen
  1. 7 1
      stmt.bmx

+ 7 - 1
stmt.bmx

@@ -102,8 +102,14 @@ Type TAssignStmt Extends TStmt
 		If TInvokeExpr( lhs ) Or TInvokeMemberExpr( lhs )
 			rhs=Null
 		Else
-			If IsPointerType(lhs.exprType, 0, TType.T_POINTER | TType.T_VAR | TType.T_VARPTR) And TNumericType(rhs.exprType) Then
+			If IsPointerType(lhs.exprType, 0, TType.T_POINTER | TType.T_VARPTR) And TNumericType(rhs.exprType) Then
 				' with pointer assignment we don't cast the numeric to a pointer
+				
+			Else If IsPointerType(lhs.exprType, 0, TType.T_VAR) And TNumericType(rhs.exprType) Then
+				' for var, we cast to the non-var type
+				Local ty:TType = lhs.exprType.Copy()
+				ty._flags :~ TType.T_VAR
+				rhs=rhs.Cast( ty )
 			Else
 				rhs=rhs.Cast( lhs.exprType )
 			End If