Bladeren bron

Abs() should return arg type. Fixes #178

woollybah 9 jaren geleden
bovenliggende
commit
79d6058084
1 gewijzigde bestanden met toevoegingen van 13 en 5 verwijderingen
  1. 13 5
      expr.bmx

+ 13 - 5
expr.bmx

@@ -2501,16 +2501,19 @@ Type TAbsExpr Extends TBuiltinExpr
 	End Method
 
 	Method Semant:TExpr()
+
 		If exprType Return Self
 
 		expr=expr.Semant()
 
-		If TIntType(expr.exprType) Or TByteType(expr.exprType) Or TShortType(expr.exprType) Then
-			exprType=New TIntType
-		Else If TLongType(expr.exprType) Then
-			exprType=New TLongType
+		If TNumericType(expr.exprType) Then
+			If TIntType(expr.exprType) Or TByteType(expr.exprType) Or TShortType(expr.exprType) Then
+				exprType=New TIntType
+			Else
+				exprType=expr.exprType
+			End If
 		Else
-			exprType=New TDoubleType
+			Err "Subexpression for 'Abs' must be of numeric type"
 		End If
 
 		Return Self
@@ -2587,6 +2590,11 @@ Type TSgnExpr Extends TBuiltinExpr
 		End If
 		
 		expr = expr.Semant()
+		
+		If Not TNumericType(expr.exprType) Then
+			Err "Subexpression for 'Sgn' must be of numeric type"
+		End If
+		
 		exprType=expr.exprType
 		Return Self
 	End Method