#lang dssl2
class Foo:
let length
def __init__(self):
pass
def len(self):
pass
def bar(self):
self.len = self.len + 1
Raises the error:
Racket v7.8/add-on/7.8/pkgs/dssl2/private/class-system.rkt:276:33: set!: cannot assign to def'd function or method
in: (set! «Foo».len (+ (struct-ref self len) 1))
This is clearly an error; the student wanted to set the length field, but was trying to set the len method instead.
But it would be nice to have an actual error for that, rather than an internal error.
The following program:
Raises the error:
This is clearly an error; the student wanted to set the
length
field, but was trying to set thelen
method instead. But it would be nice to have an actual error for that, rather than an internal error.