Exercises
-
What happens at compile time if you try to create a
uint8a value outside of its range, e.g.,uint8(-1)oruint8(1024)? -
What happens at runtime if you perform an operation which leaves the domain of an integer value, e.g.,
global x = 0; print x - 1; global y: uint8 = 255; print y + 1; global z = 1024; print cast<uint8>(z); print 4711/0; -
What happens at compile time if you access a non-existing tuple element, e.g.,
global xs = tuple(1, "a", b"c"); print xs[4711]; global xs: tuple<first: uint8, second: string> = (1, "a"); print xs.third; -
What happens at runtime if you try to get a non-existing
vectorelement, e.g.,print vector(1, 2, 3)[4711]; -
What happens at runtime if you try to dereference an invalidated iterator, e.g.,
global xs = vector(1); global it = begin(xs); print *it; xs.pop_back(); print *it; -
Can you dereference a collection's
enditerator? -
What happens at runtime if you dereference an unset
optional?