Skip to content

Impure range expressions #1397

@robinsierra

Description

@robinsierra

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug that shouldn't change language semantics when fixed.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions