calc issueshttps://gitlab.redox-os.org/redox-os/calc/-/issues2021-02-14T12:55:24Zhttps://gitlab.redox-os.org/redox-os/calc/-/issues/31Unable to install with cargo2021-02-14T12:55:24ZDaniel del CastilloUnable to install with cargoWhen trying to `cargo install calculate` I got the following error:
```
error[E0503]: cannot use `self.key_bindings` because it was mutably borrowed
--> /home/daniel/.cargo/registry/src/github.com-1ecc6299db9ec823/liner-0.4.4/src/conte...When trying to `cargo install calculate` I got the following error:
```
error[E0503]: cannot use `self.key_bindings` because it was mutably borrowed
--> /home/daniel/.cargo/registry/src/github.com-1ecc6299db9ec823/liner-0.4.4/src/context.rs:98:17
|
96 | let ed = try!(Editor::new_with_init_buffer(stdout, prompt, self, buffer));
| ---- borrow of `*self` occurs here
97 | match self.key_bindings {
98 | KeyBindings::Emacs => Self::handle_keys(keymap::Emacs::new(ed), handler),
| ^^^^^^^^^^^^^^^^^^ use of borrowed `*self`
99 | KeyBindings::Vi => Self::handle_keys(keymap::Vi::new(ed), handler),
| -- borrow later used here
error: aborting due to previous error
```
This happens because the crate still depends on liner v0.4.4, and it works on master (which uses 0.5).https://gitlab.redox-os.org/redox-os/calc/-/issues/30Unable to build on windows 72020-07-13T12:52:55ZPhilip RidoutUnable to build on windows 7Windows 7
```
>rustc --version
rustc 1.46.0-nightly (8aa18cbdc 2020-07-08)
```
I tried to build the example from README.md and got the following:
``` Updating crates.io index
Downloaded bytecount v0.1.7
Downloaded ord_subset v3....Windows 7
```
>rustc --version
rustc 1.46.0-nightly (8aa18cbdc 2020-07-08)
```
I tried to build the example from README.md and got the following:
``` Updating crates.io index
Downloaded bytecount v0.1.7
Downloaded ord_subset v3.1.1
Downloaded rustc-serialize v0.3.24
Downloaded calculate v0.5.1
Downloaded decimal v2.0.4
Downloaded liner v0.4.4
Downloaded 6 crates (1021.2 KB) in 3.61s
Compiling libc v0.2.72
Compiling winapi v0.3.9
Compiling serde v1.0.114
Compiling ord_subset v3.1.1
Compiling bytecount v0.1.7
Compiling rustc-serialize v0.3.24
Compiling decimal v2.0.4
Compiling termion v1.5.5
error[E0433]: failed to resolve: unresolved import
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\lib.rs:24:9
|
24 | pub use sys::size::terminal_size;
| ^^^
| |
| unresolved import
| help: a similar path exists: `color::env::sys`
error[E0433]: failed to resolve: unresolved import
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\lib.rs:27:9
|
27 | pub use sys::tty::{is_tty, get_tty};
| ^^^
| |
| unresolved import
| help: a similar path exists: `color::env::sys`
error[E0433]: failed to resolve: unresolved import
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.
5.5\src\async.rs:5:5
|
5 | use sys::tty::get_tty;
| ^^^
| |
| unresolved import
| help: a similar path exists: `color::env::sys`
error[E0433]: failed to resolve: unresolved import
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\raw.rs:29:5
|
29 | use sys::attr::{get_terminal_attr, raw_terminal_attr, set_terminal_attr};
| ^^^
| |
| unresolved import
| help: a similar path exists: `color::env::sys`
error[E0432]: unresolved import `sys`
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\raw.rs:28:5
|
28 | use sys::Termios;
| ^^^
| |
| unresolved import
| help: a similar path exists: `color::env::sys`
error[E0425]: cannot find function `get_tty` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\async.rs:14:36
|
14 | thread::spawn(move || for i in get_tty().unwrap().bytes() {
| ^^^^^^^ not found in this scope
error[E0425]: cannot find function `get_tty` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\async.rs:43:36
|
43 | thread::spawn(move || for i in get_tty().unwrap().bytes() {
| ^^^^^^^ not found in this scope
error[E0425]: cannot find function `set_terminal_attr` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\raw.rs:45:9
|
45 | set_terminal_attr(&self.prev_ios).unwrap();
| ^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find function `get_terminal_attr` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\raw.rs:90:23
|
90 | let mut ios = get_terminal_attr()?;
| ^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find function `raw_terminal_attr` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\raw.rs:93:9
|
93 | raw_terminal_attr(&mut ios);
| ^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find function `set_terminal_attr` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\raw.rs:95:9
|
95 | set_terminal_attr(&ios)?;
| ^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find function `set_terminal_attr` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-
1.5.5\src\raw.rs:107:9
|
107 | set_terminal_attr(&self.prev_ios)?;
| ^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find function `get_terminal_attr` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-
1.5.5\src\raw.rs:113:23
|
113 | let mut ios = get_terminal_attr()?;
| ^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find function `raw_terminal_attr` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-
1.5.5\src\raw.rs:114:9
|
114 | raw_terminal_attr(&mut ios);
| ^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find function `set_terminal_attr` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-
1.5.5\src\raw.rs:115:9
|
115 | set_terminal_attr(&ios)?;
| ^^^^^^^^^^^^^^^^^ not found in this scope
error: aborting due to 15 previous errors
Some errors have detailed explanations: E0425, E0432, E0433.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `termion`.
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
```https://gitlab.redox-os.org/redox-os/calc/-/issues/29Multiply with parentheses wont work2024-02-25T16:12:01ZCatman155Multiply with parentheses wont work**Reproduction**:
```rust
use calc::eval;
// ...
println!("{:?}", eval("2*(2*2)"));
```
**Expected behavior**: results in 8
**Actual behavior**: A error with message `InvalidOperator('*')`
**Build information**:
* `calc`: Latest vers...**Reproduction**:
```rust
use calc::eval;
// ...
println!("{:?}", eval("2*(2*2)"));
```
**Expected behavior**: results in 8
**Actual behavior**: A error with message `InvalidOperator('*')`
**Build information**:
* `calc`: Latest version from crates.io (`0.5.1`)
* `rustc -V`: `rustc 1.33.0 (2aa4c46cf 2019-02-28)`
* System: MacOS Mojave 10.14.4https://gitlab.redox-os.org/redox-os/calc/-/issues/28Support wasm-targets2020-07-12T15:35:13ZBafDyceSupport wasm-targetsCurrently, the library, unfortunately, does not support `wasm` (Web Assembly) targets for the following issues:
1) For building the library it is also necessary to compile `atty`, `clap`, and `liner` (which cannot be compiled for wasm r...Currently, the library, unfortunately, does not support `wasm` (Web Assembly) targets for the following issues:
1) For building the library it is also necessary to compile `atty`, `clap`, and `liner` (which cannot be compiled for wasm rn) and which are not actually required for the library
2) The `decimal` and `num` dependencies both depend on `rustc-serialize` which cannot be built for wasm targets
**Possible solutions**
1) This one is trivial: Just declare `atty`, `clap`, and `liner` as optional dependencies required only for the binary. I implemented this in the following patch:
https://gitlab.redox-os.org/BafDyce/calc/commit/c93cabb050f6aad680ec553225321a09e7363268#1b290eb385892bfd4870c08a785598e98c8691b7
(Note that this now requires one to run `cargo build --bin calc --features=binary` to build the cli application)
2) This is a bit harder, especially since `calc` relies quite heavily on BigInts.
For now, I based my work on a relatively old commit (right before calc switched to BigInts) and applied a patch to only use stdlib data types (removing the `decimal` and `num` dependencies).
You can see that patch here:
https://gitlab.redox-os.org/BafDyce/calc/commit/45e2e587167dd09a3d331959328e331ef2aa8bfc
(Note that this is quite an ugly (imo) hack, is almost untested, and probably only works for "small" numbers)
If you're interested, I would be more than happy to provide a MR (against the latest master) for number **1** and also for the second patch (maybe you are interested in supporting a `wasm`-branch?). Maybe it would be even possible to support wasm-targets without using an outdated + hacked version of `calc`?
PS: I applied both of my patches in a wasm-branch on my fork: https://gitlab.redox-os.org/BafDyce/calc/commits/wasmhttps://gitlab.redox-os.org/redox-os/calc/-/issues/27Support `eval_with_vars()`2018-09-10T18:02:27ZBafDyceSupport `eval_with_vars()`It would be great if the library could support variables in the expression and evaluate them at runtime.
See the following example:
```rust
eval_with_vars("2 + {nn}", { xx = 3 }) // I know that this code won't work/compile.
```
Ideall...It would be great if the library could support variables in the expression and evaluate them at runtime.
See the following example:
```rust
eval_with_vars("2 + {nn}", { xx = 3 }) // I know that this code won't work/compile.
```
Ideally, this would support a data structure which can hold arbitrary variable names (a Hashmap?) without limiting the type of the values.
Maybe something like:
```rust
trait GetValue {
fn get_value(&self) -> Value;
}
fn eval_with_vars<T>(expression: &str, vars: &HashMap<&str, T>) -> Value
where T: GetValue
{
// stuff
}
```https://gitlab.redox-os.org/redox-os/calc/-/issues/26Addition with zero yields BigInt parsing errors2019-04-11T15:56:47ZMichael Aaron Murphymmstick@pm.meAddition with zero yields BigInt parsing errors*Created by: xTibor*
**Reproduction**:
```rust
extern crate calc;
fn main() {
let expressions = &["1+0", "0+1", "0+0", "(1+0)+0"];
for e in expressions.iter() {
println!("{} = {:?}", e, calc::eval(e));
}
...*Created by: xTibor*
**Reproduction**:
```rust
extern crate calc;
fn main() {
let expressions = &["1+0", "0+1", "0+0", "(1+0)+0"];
for e in expressions.iter() {
println!("{} = {:?}", e, calc::eval(e));
}
}
```
**Expected behavior**:
```
1+0 = Ok(Integral(BigInt { sign: Plus, data: BigUint { data: [1] } }, Dec))
0+1 = Ok(Integral(BigInt { sign: Plus, data: BigUint { data: [1] } }, Dec))
0+0 = Ok(Integral(BigInt { sign: Plus, data: BigUint { data: [0] } }, Dec))
(1+0)+0 = Ok(Integral(BigInt { sign: Plus, data: BigUint { data: [1] } }, Dec))
```
**Actual behavior**:
```
1+0 = Ok(Integral(BigInt { sign: Plus, data: BigUint { data: [1] } }, Dec))
0+1 = Err(InvalidNumber("failed to parse bigint/biguint"))
0+0 = Err(InvalidNumber("failed to parse bigint/biguint"))
(1+0)+0 = Err(InvalidNumber("failed to parse bigint/biguint"))
```
**Build information**:
`rustc -V`: `rustc 1.28.0-nightly (5d0631a64 2018-05-30)`
`git rev-parse HEAD`: 90c85a7ead79af4f76fa6f3804009d6e3b873258
System: KDE neon 5.12 (Ubuntu 16.04)https://gitlab.redox-os.org/redox-os/calc/-/issues/25Integer Divide2018-06-10T16:52:21ZMichael Aaron Murphymmstick@pm.meInteger DivideWould be nice to have, so that
96 // 10 = 9
96 % 10 = 6Would be nice to have, so that
96 // 10 = 9
96 % 10 = 6https://gitlab.redox-os.org/redox-os/calc/-/issues/24Stack overflow on deeply nested expressions2019-07-31T20:02:10ZMichael Aaron Murphymmstick@pm.meStack overflow on deeply nested expressions*Created by: xTibor*
**Reproduction**:
```rust
extern crate calc;
fn main() {
// Might need more parens on other systems
calc::eval("((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...*Created by: xTibor*
**Reproduction**:
```rust
extern crate calc;
fn main() {
// Might need more parens on other systems
calc::eval("((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((").unwrap();
}
```
**Expected behavior**:
It would be nice to have a recursion limit in the parser and throwing an error when that limit is reached.
**Actual behavior**:
```
thread 'main' has overflowed its stack
fatal runtime error: stack overflow
Aborted
```
**Build information**:
`rustc -V`: `rustc 1.28.0-nightly (952f344cd 2018-05-18)`
`git rev-parse HEAD`: 25ea8856d7fee560e46303797bb960f003d0f128
System: KDE neon 5.12 (Ubuntu 16.04)https://gitlab.redox-os.org/redox-os/calc/-/issues/23Incorrect results with unary minus signs2018-06-10T06:47:01ZMichael Aaron Murphymmstick@pm.meIncorrect results with unary minus signs*Created by: xTibor*
**Reproduction**:
```rust
use calc::eval;
// ...
println!("{:?}", eval("-1 + 1"));
```
**Expected behavior**:
`0`
**Actual behavior**:
`-2`
Calc interprets that expression as `-(1 + 1)`
**Build inform...*Created by: xTibor*
**Reproduction**:
```rust
use calc::eval;
// ...
println!("{:?}", eval("-1 + 1"));
```
**Expected behavior**:
`0`
**Actual behavior**:
`-2`
Calc interprets that expression as `-(1 + 1)`
**Build information**:
* `calc`: 233711fdcb1c793fb6feef895ad88e7f0dcea39a
* `rustc -V`: `rustc 1.23.0-nightly (d6b06c63a 2017-11-09)`
* System: KDE neon 5.11 (Ubuntu 16.04 LTS)
https://gitlab.redox-os.org/redox-os/calc/-/issues/22Overflow panics on multiplication and exponentiation2018-06-10T06:47:01ZMichael Aaron Murphymmstick@pm.meOverflow panics on multiplication and exponentiation*Created by: xTibor*
**Reproduction**:
```rust
use calc::eval;
// ...
println!("{:?}", eval("2 ** 63"));
println!("{:?}", eval("3040000000 * 3040000000"));
```
**Expected behavior**:
Getting a `CalcError::WouldOverflow` result...*Created by: xTibor*
**Reproduction**:
```rust
use calc::eval;
// ...
println!("{:?}", eval("2 ** 63"));
println!("{:?}", eval("3040000000 * 3040000000"));
```
**Expected behavior**:
Getting a `CalcError::WouldOverflow` result.
**Actual behavior**:
A panic with an `'attempt to multiply with overflow'` message.
**Build information**:
* `calc`: Latest version from crates.io (`0.5.*`)
* `rustc -V`: `rustc 1.23.0-nightly (e340996ff 2017-11-02)`
* System: KDE neon 5.11 (Ubuntu 16.04 LTS)
**Misc**:
I encountered this issue via Ion's [arithmetic expansions](https://doc.redox-os.org/ion-manual/ch05-04-arithmetic.html).
https://gitlab.redox-os.org/redox-os/calc/-/issues/21Conversion for f32 / f64 into Value2018-06-10T06:47:01ZMichael Aaron Murphymmstick@pm.meConversion for f32 / f64 into Value*Created by: Refefer*
Any thoughts of ways to convert f32 / f64 (as well as other native data types) into Value objects? *Created by: Refefer*
Any thoughts of ways to convert f32 / f64 (as well as other native data types) into Value objects? https://gitlab.redox-os.org/redox-os/calc/-/issues/20Add `examples` subprojects2018-06-10T06:47:01ZMichael Aaron Murphymmstick@pm.meAdd `examples` subprojects*Created by: huntergoldstein*
# Problem
#19 shouldn't have happened. It was the intent that users could construct their own `Environment`s and pass them into `parse::eval` et al.
# Solution
Create examples sub-projects that are int...*Created by: huntergoldstein*
# Problem
#19 shouldn't have happened. It was the intent that users could construct their own `Environment`s and pass them into `parse::eval` et al.
# Solution
Create examples sub-projects that are integrated with `cargo test` that serve as example libraries / applications. These would serve as regression tests for API changes. https://gitlab.redox-os.org/redox-os/calc/-/issues/19Expose Environment trait2018-06-10T06:47:01ZMichael Aaron Murphymmstick@pm.meExpose Environment trait*Created by: Refefer*
Quite simply, could we expose the Environment trait from the library? This could be quite the useful library if we could implement our own!*Created by: Refefer*
Quite simply, could we expose the Environment trait from the library? This could be quite the useful library if we could implement our own!https://gitlab.redox-os.org/redox-os/calc/-/issues/17128-bit decimal float support2018-06-10T06:47:01ZMichael Aaron Murphymmstick@pm.me128-bit decimal float supportTo make the results more useful / accurate, we should probably do away with using floating point math entirely, and instead opt for using `d128` from the [decimal](https://github.com/alkis/decimal) crate.To make the results more useful / accurate, we should probably do away with using floating point math entirely, and instead opt for using `d128` from the [decimal](https://github.com/alkis/decimal) crate.https://gitlab.redox-os.org/redox-os/calc/-/issues/15Utilities for command line application2018-06-10T06:47:01ZMichael Aaron Murphymmstick@pm.meUtilities for command line application*Created by: huntergoldstein*
# Problem
Currently the command line application is fairly bare-bones. It just reads lines from `stdin` and uses a fairly simple arg-checking strategy.
# Solution
- [x] Have `calc` determine if `stdin` `...*Created by: huntergoldstein*
# Problem
Currently the command line application is fairly bare-bones. It just reads lines from `stdin` and uses a fairly simple arg-checking strategy.
# Solution
- [x] Have `calc` determine if `stdin` `isatty` and run interactively or not
- [x] Use a line editing library such as `liner`
- [x] Use an argument parsing library such as `clap`
https://gitlab.redox-os.org/redox-os/calc/-/issues/12Separate monolithic `lib.rs` into sub-modules with distinct responsibilities2018-06-10T06:47:01ZMichael Aaron Murphymmstick@pm.meSeparate monolithic `lib.rs` into sub-modules with distinct responsibilities*Created by: huntergoldstein*
Having all of the functions and libraries in a single module seems like a poor idea. It would be better to at least move `tokenize` and its data structures into some `token.rs` and `parse`, `d_expr`, `e_exp...*Created by: huntergoldstein*
Having all of the functions and libraries in a single module seems like a poor idea. It would be better to at least move `tokenize` and its data structures into some `token.rs` and `parse`, `d_expr`, `e_expr`, etc. into some `parse.rs`. Then move the appropriate tests to each module.https://gitlab.redox-os.org/redox-os/calc/-/issues/11Chained functions don't work correctly in respect to division.2018-06-10T06:47:01ZMichael Aaron Murphymmstick@pm.meChained functions don't work correctly in respect to division.*Created by: mgmoens*
**Reproduction**: try calculating log (4) / log (2).
**Expected behavior**: Calc should return 2.
**Actual behavior**: Calc returns 1.1234502189822873, which is the same as log ( 4 / log (2) ).
**Build in...*Created by: mgmoens*
**Reproduction**: try calculating log (4) / log (2).
**Expected behavior**: Calc should return 2.
**Actual behavior**: Calc returns 1.1234502189822873, which is the same as log ( 4 / log (2) ).
**Build information**: ` [shell]$ git rev-parse HEAD
a6398c1469922452eea52b4a3255e8dc1c0441a8`
**Misc**: [optional: for other relevant information that should be known or cannot be described in the other fields.]
------https://gitlab.redox-os.org/redox-os/calc/-/issues/10Allow hexadecimal input2018-06-10T06:47:01ZJeremy SollerAllow hexadecimal inputI think it would be useful, especially with bitwise operations, to allow hexadecimal input and output.
Basically, any number prepended with `0x` would be parsed as hexadecimal. All others would be decimal. If there is any input that i...I think it would be useful, especially with bitwise operations, to allow hexadecimal input and output.
Basically, any number prepended with `0x` would be parsed as hexadecimal. All others would be decimal. If there is any input that is hexadecimal, then the output should be hexadecimal, and prepended with `0x`.
Examples:
`0x400 * 2 = 0x800`
`0x123 | 0x321 = 0x323`
`200 * 0x1 = 0xC8`https://gitlab.redox-os.org/redox-os/calc/-/issues/9Long Term Goals / Features2018-06-10T06:47:01ZMichael Aaron Murphymmstick@pm.meLong Term Goals / Features*Created by: mgmoens*
A couple of things I'd like:
- variables: the symbolic and the substituted kind. I.e. y = x + 1 and y² would result in (x² +2x +1)
- differential calculus: symbolic and numeric integration and differentiati...*Created by: mgmoens*
A couple of things I'd like:
- variables: the symbolic and the substituted kind. I.e. y = x + 1 and y² would result in (x² +2x +1)
- differential calculus: symbolic and numeric integration and differentiation. It doesn't really have to go all that far, but it's something I've been craving for some time. If I need to calculate an integral I forgot (or that's too hard or when I'm too lazy) I'd need to google it, hope Wolfram has it or get a license from school to open Maple and calculate it that way...
I think I'm not the only user in want of something like this. But it's probably pretty hard.https://gitlab.redox-os.org/redox-os/calc/-/issues/7Parens bug2018-06-10T06:47:02ZMichael Aaron Murphymmstick@pm.meParens bug*Created by: mgmoens*
**Reproduction**: try to use calc ((15+45)) in ion on my branch with the crate added in.
**Expected output **: 60
**Actual output**: ion: syntax error: '(' at position 6 is out of place
**Misc**: I'm prob...*Created by: mgmoens*
**Reproduction**: try to use calc ((15+45)) in ion on my branch with the crate added in.
**Expected output **: 60
**Actual output**: ion: syntax error: '(' at position 6 is out of place
**Misc**: I'm probably the root for this bug :p I think I introduced a couple off by one out of bounds bugs.
------
_If the above does not fit the nature of the issue feel free to modify it._