about summary refs log tree commit diff stats
path: root/immutable-error.mu
blob: 25554b2fc2f4e28f86c7e0f99c1b9e8c1013f823 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
# compare mutable.mu

def main [
  local-scope
  x:&:num <- new number:type
  foo x
]

def foo x:&:num [
  local-scope
  load-inputs
  *x <- copy 34  # will cause an error because x is immutable in this function
]
>os.path.dirname(__file__)) \ if x.startswith('tc_') ] def init(): sys.path.append(os.path.abspath(os.path.join(sys.path[0], '..'))) class Fake(object): def __getattr__(self, attrname): val = Fake() self.__dict__[attrname] = val return val def __call__(self, *_, **__): return Fake() def __clear__(self): self.__dict__.clear() def __iter__(self): return iter(()) class OK(Exception): pass def raise_ok(*_, **__): raise OK()