'+=' etc for all floating point types

This commit is contained in:
Araq
2012-05-29 00:42:28 +02:00
parent f3980eb24a
commit b5d8e8bfaa
6 changed files with 21 additions and 13 deletions

View File

@@ -144,7 +144,7 @@ proc mapSetType(typ: PType): TCTypeKind =
proc mapType(typ: PType): TCTypeKind =
case typ.kind
of tyNone: result = ctVoid
of tyNone, tyStmt: result = ctVoid
of tyBool: result = ctBool
of tyChar: result = ctChar
of tySet: result = mapSetType(typ)

View File

@@ -869,8 +869,9 @@ proc typeAllowedAux(marker: var TIntSet, typ: PType, kind: TSymKind): bool =
result = typeAllowedAux(marker, t.sons[0], skResult)
of tyExpr, tyStmt, tyTypeDesc:
result = true
of tyGenericBody, tyGenericParam, tyForward, tyNone, tyGenericInvokation, tyTypeClass:
result = false #InternalError('shit found');
of tyGenericBody, tyGenericParam, tyForward, tyNone, tyGenericInvokation,
tyTypeClass:
result = false
of tyEmpty, tyNil:
result = kind == skConst
of tyString, tyBool, tyChar, tyEnum, tyInt..tyBigNum, tyCString, tyPointer:

View File

@@ -2184,19 +2184,19 @@ proc `*=`*[T](x: var ordinal[T], y: ordinal[T]) {.inline, noSideEffect.} =
## Binary `*=` operator for ordinals
x = x * y
proc `+=` *(x: var float, y:float) {.inline, noSideEffect.} =
proc `+=`*[T: float|float32|float64] (x: var T, y: T) {.inline, noSideEffect.} =
## Increments in placee a floating point number
x = x + y
proc `-=` *(x: var float, y:float) {.inline, noSideEffect.} =
proc `-=`*[T: float|float32|float64] (x: var T, y: T) {.inline, noSideEffect.} =
## Decrements in place a floating point number
x = x - y
proc `*=` *(x: var float, y:float) {.inline, noSideEffect.} =
proc `*=`*[T: float|float32|float64] (x: var T, y: T) {.inline, noSideEffect.} =
## Multiplies in place a floating point number
x = x * y
proc `/=` *(x: var float, y:float) {.inline, noSideEffect.} =
proc `/=`*[T: float|float32|float64] (x: var T, y: T) {.inline, noSideEffect.} =
## Divides in place a floating point number
x = x / y

View File

@@ -0,0 +1,9 @@
discard """
errormsg: "type mismatch"
"""
type
TE1 = enum eA, eB
TE2 = enum eC, eD
assert eA != eC

View File

@@ -1,4 +1,5 @@
discard """
disabled: true
output: '''StmtList
VarSection
IdentDefs
@@ -11,6 +12,8 @@ output: '''StmtList
IntLit 56'''
"""
# disabled; can't work as the output is done by the compiler
import macros
#emit("type\n TFoo = object\n bar: int")

View File

@@ -33,14 +33,9 @@ version 0.9.0
error handling more light-weight
people also want ``inc a; inc b``
Bugs
----
- bug: returning a tyVar does not mean it is save to return it:
proc forward[T](x: var T): var T = result = x
proc p(): var int =
var x: int
# reject this call via alias analysis:
result = forward(x)
- bug: stress testing basic method example (eval example)
without ``-d:release`` leaks memory?