tov / dssl2

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

Slightly nicer error message when a body is all definitions. #18

Closed stamourv closed 4 years ago

stamourv commented 4 years ago

Currently, this program:

#lang dssl2
def foo():
    def bar():
        3

raises an error in terms of the Racket expansion.

The PR catches these kinds of errors, and produces a slightly nicer error message.

Two issues that remain:

tov commented 4 years ago

I don't think I do have syntax error tests…

tov commented 4 years ago

Is it necessarily wrong to end with a definition? Instead of improving this error message, maybe we should make the result None in that case.

stamourv commented 4 years ago

Is there a non-mistake situation where you have definitions, but no expression in the body? I'd imagine that that error would catch a lot of oversights, e.g., missing recursing starting point.

tov commented 4 years ago

It’s never ultimately useful, but there are definitely cases where you could temporarily have a definition last in a block. And notably, Python allows it.

stamourv commented 4 years ago

Alright, either way works for me. The more time-sensitive PR is the other one anyway. Any ETA on that one?

tov commented 4 years ago

So it turns out it wasn’t just def that did this—let-with-no-RHS, struct, class, and interface did as well. I implemented my solution on a branch, block-end-fix. If you’re happy with that then I’ll merge it.

stamourv commented 4 years ago

That looks fine, I'm happy with that. No tests?

tov commented 4 years ago

Yeah, okay, a couple tests.