chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A facility for debugging type issues


From: megane
Subject: Re: A facility for debugging type issues
Date: Fri, 06 Aug 2021 11:52:48 +0300
User-agent: mu4e 1.0; emacs 28.0.50

Evan Hanson <evhan@foldling.org> writes:

> Hey megane!
>
> On 2021-04-10 11:24, megane wrote:
>> here's a POC tool I've been using for a year. It prints the types known to
>> scrutinizer in the current scope.
>
> Finally having a look at this, and I have to say, it is very cool. It
> still applies cleanly too! :)
>
> What were you thinking ought to be done with it?

This patch was just for probing if there is interested for this kind of
tool.

I remember people asking for a tool which would show the types
scrutinizer knows. This is one way to show those types.

Was this the kind of thing people were looking for?

> Personally I think a
> facility like this would be very nice to add "for real", if it were
> guarded behind a debugging flag of some kind (maybe another "-debug"
> option?), or perhaps only enabled with DEBUGBUILD. So, normal
> compilation would just ignore these nodes, but we could still add the
> feature properly. Was that your thinking?

I would not hide this in any way. User can use it to

1. Debug issues with type related warnings in normal code

2. Build intuition about how the scrutinizer works on different kind of
   code.

I use it for the first purpose quite frequently, and have a keyboard
shortcut to insert the hole.

Here's an example of usage:

(let ((foo (lambda (x)
             (let loop ((y 0))
               (the * '(##core#type-hole "hole 1"))
               (if (= 10 y)
                   (if (pair? x)
                       (let ((f foo))
                         (the * '(##core#type-hole "true branch"))
                         x)
                       (begin
                         (the * '(##core#type-hole "false branch"))
                         x))
                   (cons y (loop (add1 y))))))))
  (the * '(##core#type-hole "hole 3")))

Output:
;; Type hole encountered:
;;      x : *
;;   loop : *
;;      y : *
;;   ----------------------------------------
;;   "hole 1"
;;
;; Type hole encountered:
;;   loop : *
;;      y : number
;;      x : pair
;;      f : *
;;   ----------------------------------------
;;   "true branch"
;;
;; Type hole encountered:
;;   loop : *
;;      y : number
;;      x : (not pair)
;;   ----------------------------------------
;;   "false branch"
;;
;; Type hole encountered:
;;   foo : (procedure foo (*) . *)
;;   ----------------------------------------
;;   "hole 3"

Before type-hole I used to use the more tedious pattern

  (compiler-typecase <insert-type-here> ((not *) 1))

to inspect the types.

As for what the nodes should evaluate to, 3 ideas would be
1. To drop them completely from the output
2. To turn holes into calls to error
3. To stop the compilation with error after phase X



reply via email to

[Prev in Thread] Current Thread [Next in Thread]