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

Variable's value being updated without reassigning after running skip. #8756

Closed
2 tasks done
0xSpraggins opened this issue Aug 27, 2024 · 1 comment
Closed
2 tasks done
Labels
T-bug Type: bug T-needs-triage Type: this issue needs to be labelled

Comments

@0xSpraggins
Copy link

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (d28a337 2024-08-27T00:19:36.462740000Z)

What command(s) is the bug in?

forge test

Operating System

macOS (Apple Silicon)

Describe the bug

Within a foundry test script I am assigning a uint256 variable the value of block.timestamp. Later on after running skip() the original variable automatically updats to reflect the new block.timestamp without the variable being manually reassigned in the code.

Current Code:

uint256 startingTime = block.timestamp;
console2.log("startingTime: ", startingTime) // Returns 604801

skip(180 days);

console2.log("startingTime: ", startingTime) // Returns 16156801
@0xSpraggins 0xSpraggins added T-bug Type: bug T-needs-triage Type: this issue needs to be labelled labels Aug 27, 2024
@DaniPopes
Copy link
Member

This happens with via-ir

See

You can use vm.getBlockTimestamp() and other getter methods in vm to avoid compiler optimizations.

@DaniPopes DaniPopes closed this as not planned Won't fix, can't repro, duplicate, stale Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug T-needs-triage Type: this issue needs to be labelled
Projects
None yet
Development

No branches or pull requests

2 participants