Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

twice action when using @ operator at version 0.3.0 #14

Closed
sv-atoslav opened this issue Aug 4, 2022 · 2 comments · Fixed by #15
Closed

twice action when using @ operator at version 0.3.0 #14

sv-atoslav opened this issue Aug 4, 2022 · 2 comments · Fixed by #15

Comments

@sv-atoslav
Copy link

my program and OS versions

$calc --version
calc 0.3.0
$lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.1 LTS
Release:	22.04
Codename:	jammy

steps to reproduce 1

$calc --i64
[1]: 528500/100
5285
[2]: @/2
1321
[3]: 5285/2
2642
[4]:
Error: Interrupted

steps to reproduce 2

$calc --u64
[0]: 2+2*2
6
[1]: @*100
60000
[2]: @*-1
operation `-` not implemented for u64
[2]: @*2
2400
[3]: @+1
1202
[4]:
Error: Interrupted

steps to reproduce 3

[0]: 0.1+0.2
.30000000000000004 (skip, because https://0.30000000000000004.com/ )
[1]: @+0.003
.30600000000000005
[2]: @+0.0001
.3032
[3]: 
Error: Interrupted
@coriolinus
Copy link
Owner

Interesting! Thanks for reporting. I've added some tests in cf8f230, which demonstrate that the error is not in the core context/evaluation engine. However, I've successfully repro'd the issue locally. Therefore it looks like the operation is getting evaluated twice somehow. I will continue to investigate.

coriolinus added a commit that referenced this issue Aug 7, 2022
Fixes #14.

We'd been evaluating expressions twice: once to get a numeric result
to insert into the history, and again to get the string output which
was formatted according to user request. That turned out to be a bad
idea when the expression contained a back-reference, because the
back-reference was updated before the display version was re-calculated.

Evaluating once and then updating history is absolutely the way to
go here.
@coriolinus coriolinus linked a pull request Aug 7, 2022 that will close this issue
@coriolinus
Copy link
Owner

Fixed in #15. Thanks for reporting this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants