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

Impure range expressions #1397

Closed
robinsierra opened this issue Apr 17, 2019 · 1 comment · Fixed by #1424
Labels
bug

Comments

@robinsierra
Copy link

@robinsierra robinsierra commented Apr 17, 2019

Version Information

  • vyper Version: 0.1.0b9
  • Tested with Remix IDE

Currently Vyper allows range expressions of the form range(x, x + n) where n is a constant. A weird case happens when x is impure:

glob: int128

@public
def foo() -> int128:
	self.glob += 1
	return 5


@public
def bar():
	for i in range(self.foo(), self.foo() + 1):
		pass

Even though the range expression contains two calls to self.foo() it is only executed once, which feels very unintuitive at best. In general, it would be nice to have some documentation for loops/range expressions (especially if this is the intended behavior).

@jacqueswww

This comment has been minimized.

Copy link
Collaborator

@jacqueswww jacqueswww commented May 2, 2019

I agree, I don't think this should be allowed at all, ie. functions called in range() have to be @constant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.