michaelballantyne / hosted-minikanren

An optimizing compiler implementation of miniKanren for Racket
MIT License
2 stars 2 forks source link

Unfortunately imprecise syntax error reporting #4

Closed jasonhemann closed 3 years ago

jasonhemann commented 3 years ago

E.g.

#lang racket
(require minikanren-ee)

(define (foobaro a)
  (conde
    [(conde
       [(conde
          [(conde
             [(conde
                [(conde
                   [(conde
                      [(conde
                         [(conde
                            [(conde
                               [(conde
                                  [(conde
                                     [(conde
                                        [(conde
                                           [(conde
                                              [(conde
                                                 [(conde
                                                    [(conde
                                                       [(conde
                                                          [(conde
                                                             [(smybolo a)])])])])])])])])])])])])])])])])])])])]))

Lets me know that I made a mistake as follows:

; test.rkt:5:2: conde: illegal use of syntax
;   in: (conde ((conde ((conde ((conde ((conde ((conde ((conde ((conde ((conde ((conde ((conde ((conde ((conde ((conde ((conde ((conde ((conde ((conde ((conde ((conde ((smybolo a)))))))))))))))))))))))))))))))))))))))))
;   value at phase 1: #<goal-macro-rep>

It would be nicer for minikanren-ee to pinpoint the mistake for the user.

michaelballantyne commented 3 years ago

https://github.com/michaelballantyne/minikanren-ee/commit/33f5e03f8451f92f7ec073579e58f0d57d12ef59

Better?

jasonhemann commented 3 years ago

@michaelballantyne yes that's better in that the error message is better formatted.

In this example, it feels like the user would want the error reported at the inner-most conde expression. Right now a small, local error will be reported at the largest enclosing minikanren-ee macro, and that makes it unfortunately difficult to track down.

michaelballantyne commented 3 years ago

@jasonhemann I think you're expecting the wrong error! The first-encountered problem with this program is that it uses conde (a goal syntax) inside define (a Racket, not miniKanren, context).

If you fix your program to use define-relation I think you'll get the error you're looking for.

jasonhemann commented 3 years ago

Oh! Yes! Great!