Idorobots / spartan

A small Lisp dialect that serves me as a test bed for programming language features.
MIT License
13 stars 3 forks source link

Extra "Bad define syntax" error when it is the only expression and the variable name is unused. #178

Open Idorobots opened 8 months ago

Idorobots commented 8 months ago

For this input:

(define foo 23)

It produced the following output:

test/sprtn/errors/unused.sprtn(1,0): Bad `define` syntax, not allowed in this context:
  1 |(define foo 23)
    |^^^^^^^^^^^^^^^

test/sprtn/errors/unused.sprtn(1,8): Unused variable `foo`, rename to `_` to avoid this error:
  1 |(define foo 23)
    |        ^^^

The first error is not warranted and indeed it disappears if the input is prepended by any other expression, despite the define remaining in the same scope.

Idorobots commented 8 months ago

This is done so that a scope needs to return a value, but at top level the resulting module should be the value. It should be laxed when #55 is implemented.