Permalink
Browse files

Fix livelock unearthed by go-hep/csvutil#3. Closes #149.

  • Loading branch information...
cznic committed Jan 28, 2017
1 parent 7a63cd7 commit 7ff8278d6a6a9dd79b1de0ff5fec857590e8247f
Showing with 97 additions and 82 deletions.
  1. +1 −0 Makefile
  2. +6 −6 builtin.go
  3. +13 −13 coerce.go
  4. +39 −39 etc.go
  5. +2 −2 expr.go
  6. +1 −1 file.go
  7. +34 −20 ql.go
  8. +1 −1 ql.y
View
@@ -14,6 +14,7 @@ all: editor scanner.go parser.go
unused . || true
misspell *.go
gosimple || true
unconvert -apply
go install ./...
bench: all
View
@@ -126,27 +126,27 @@ func builtinAvg(arg []interface{}, ctx map[interface{}]interface{}) (v interface
case complex64:
return complex64(complex128(x) / complex(float64(data.n), 0)), nil
case complex128:
return complex64(complex128(x) / complex(float64(data.n), 0)), nil
return complex64(x / complex(float64(data.n), 0)), nil
case float32:
return float32(float64(x) / float64(data.n)), nil
case float64:
return float64(x) / float64(data.n), nil
return x / float64(data.n), nil
case int8:
return int8(int64(x) / int64(data.n)), nil
case int16:
return int16(int64(x) / int64(data.n)), nil
case int32:
return int32(int64(x) / int64(data.n)), nil
case int64:
return int64(int64(x) / int64(data.n)), nil
return x / int64(data.n), nil
case uint8:
return uint8(uint64(x) / data.n), nil
case uint16:
return uint16(uint64(x) / data.n), nil
case uint32:
return uint32(uint64(x) / data.n), nil
case uint64:
return uint64(uint64(x) / data.n), nil
return x / data.n, nil
}
}
@@ -216,9 +216,9 @@ func builtinComplex(arg []interface{}, _ map[interface{}]interface{}) (v interfa
case idealUint:
return idealComplex(complex(float64(re), float64(im.(idealUint)))), nil
case float32:
return complex(float32(re), im.(float32)), nil
return complex(re, im.(float32)), nil
case float64:
return complex(float64(re), im.(float64)), nil
return complex(re, im.(float64)), nil
case int8:
return complex(float64(re), float64(im.(int8))), nil
case int16:
View
@@ -93,13 +93,13 @@ func coerce1(inVal, otherVal interface{}) (coercedInVal interface{}) {
//case idealUint:
//case bool:
case complex64:
return complex64(complex(float32(x), 0))
return complex(float32(x), 0)
case complex128:
return complex128(complex(float64(x), 0))
return complex(float64(x), 0)
case float32:
return float32(float64(x))
case float64:
return float64(float64(x))
return float64(x)
//case int8:
//case int16:
//case int32:
@@ -130,9 +130,9 @@ func coerce1(inVal, otherVal interface{}) (coercedInVal interface{}) {
}
//case bool:
case complex64:
return complex64(complex(float32(x), 0))
return complex(float32(x), 0)
case complex128:
return complex128(complex(float64(x), 0))
return complex(float64(x), 0)
case float32:
return float32(int64(x))
case float64:
@@ -150,7 +150,7 @@ func coerce1(inVal, otherVal interface{}) (coercedInVal interface{}) {
return int32(int64(x))
}
case int64:
return int64(int64(x))
return int64(x)
//case string:
case uint8:
if x >= 0 && x <= math.MaxUint8 {
@@ -190,9 +190,9 @@ func coerce1(inVal, otherVal interface{}) (coercedInVal interface{}) {
return idealUint(int64(x))
//case bool:
case complex64:
return complex64(complex(float32(x), 0))
return complex(float32(x), 0)
case complex128:
return complex128(complex(float64(x), 0))
return complex(float64(x), 0)
case float32:
return float32(int64(x))
case float64:
@@ -204,7 +204,7 @@ func coerce1(inVal, otherVal interface{}) (coercedInVal interface{}) {
case int32:
return int32(int64(x))
case int64:
return int64(int64(x))
return int64(x)
//case string:
case uint8:
return uint8(int64(x))
@@ -237,9 +237,9 @@ func coerce1(inVal, otherVal interface{}) (coercedInVal interface{}) {
return idealUint(uint64(x))
//case bool:
case complex64:
return complex64(complex(float32(x), 0))
return complex(float32(x), 0)
case complex128:
return complex128(complex(float64(x), 0))
return complex(float64(x), 0)
case float32:
return float32(uint64(x))
case float64:
@@ -258,7 +258,7 @@ func coerce1(inVal, otherVal interface{}) (coercedInVal interface{}) {
}
case int64:
if x <= math.MaxInt64 {
return int64(int64(x))
return int64(x)
}
//case string:
case uint8:
@@ -274,7 +274,7 @@ func coerce1(inVal, otherVal interface{}) (coercedInVal interface{}) {
return uint32(int64(x))
}
case uint64:
return uint64(uint64(x))
return uint64(x)
case *big.Int:
return big.NewInt(0).SetUint64(uint64(x))
case *big.Rat:
Oops, something went wrong.

0 comments on commit 7ff8278

Please sign in to comment.