Skip to content

Bad error message when accidentally setting a method #25

@stamourv

Description

@stamourv

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions