mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 21:40:32 +00:00
'+=' etc for all floating point types
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
9
tests/reject/tenummix.nim
Normal file
9
tests/reject/tenummix.nim
Normal file
@@ -0,0 +1,9 @@
|
||||
discard """
|
||||
errormsg: "type mismatch"
|
||||
"""
|
||||
|
||||
type
|
||||
TE1 = enum eA, eB
|
||||
TE2 = enum eC, eD
|
||||
|
||||
assert eA != eC
|
||||
@@ -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")
|
||||
|
||||
7
todo.txt
7
todo.txt
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user