tov / dssl2

A data structures student language, version 2
MIT License
9 stars 5 forks source link

Bad error message when accidentally setting a method #25

Open stamourv opened 4 years ago

stamourv commented 4 years ago

The following program:

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