plait icon indicating copy to clipboard operation
plait copied to clipboard

Generated type error for recursive call is not very helpful

Open stites opened this issue 6 months ago • 0 comments

I had a typo in a recursive call and stumbled across this a gnarly type error. The a minimal example to reproduce the error is as follows:

#lang plait

(define (f g x)
   (f g (x g)))

The original error overflowed my terminal's buffer and I couldn't see the reason for the error. The minimal example tells me that I found a cycle in the type-checker:

typecheck failed: possible cycle in type constraints; increase #:fuel to try more
/home/stites/git/racket/playground/test.rkt:15:9: typecheck failed: possible cycle in type constraints; increase #:fuel to try more
  type mismatch: ('a
 ('a
  ->
  ('a
   ->
   ('a
    ->
    ('a
     ->
     ('a
      ->
      ('a
       ->
       ('a
        ->
        ('a
         ->
         ('a
          ->
          ('a
           ->
           ('a
            ->
            ('a
             ->
             ('a
              ->
              ('a
               ->
               ('a
                ->
                ('a
                 ->
                 ('a
                  ->
                  ('a
                   ->
                   ('a
                    ->
                    ('a
                     ->
                     ('a
                      ->
                      ('a
                       ->
                       ('a
                        ->
                        ('a
                         ->
                         ('a
                          ->
                          ('a
                           ->
                           ('a
                            ->
                            ('a
                             ->
                             ('a
                              ->
                              ('a
                               ->
                               ('a
                                ->
                                ('a
                                 ->
                                 ('a
                                  ->
                                  ('a
                                   ->
                                   ('a
                                    ->
                                    ('a
                                     ->
                                     ('a
                                      ->
                                      ('a
                                       ->
                                       ('a
                                        ->
                                        ('a
                                         ->
                                         ('a
                                          ->
                                          ('a
                                           ->
                                           ('a
                                            ->
                                            ('a
                                             ->
                                             ('a
                                              ->
                                              ('a
                                               ->
                                               ('a
                                                ->
                                                ('a
                                                 ->
                                                 ('a
                                                  ->
                                                  ('a
                                                   ->
                                                   ('a
                                                    ->
                                                    ('a
                                                     ->
                                                     ('a
                                                      ->
                                                      ('a
                                                       ->
                                                       ('a
                                                        ->
                                                        ('a
                                                         ->
                                                         ('a
                                                          ->
                                                          ('a
                                                           ->
                                                           ('a
                                                            ->
                                                            ('a
                                                             ->
                                                             ('a
                                                              ->
                                                              ('a
                                                               ->
                                                               ('a
                                                                ->
                                                                ('a
                                                                 ->
                                                                 ('a
                                                                  ->
                                                                  ('a
                                                                   ->
                                                                   ('a
                                                                    ->
                                                                    ('a
                                                                     ->
                                                                     ('a
                                                                      ->
                                                                      ('a
                                                                       ->
                                                                       ('a
                                                                        ->
                                                                        ('a
                                                                         ->
                                                                         ('a
                                                                          ->
                                                                          ('a
                                                                           ->
                                                                           ('a
                                                                            ->
                                                                            ('a
                                                                             ->
                                                                             ('a
                                                                              ->
                                                                              ('a
                                                                               ->
                                                                               ('a
                                                                                ->
                                                                                ('a
                                                                                 ->
                                                                                 ('a
                                                                                  ->
                                                                                  ('a
                                                                                   ->
                                                                                   ('a
                                                                                    ->
                                                                                    ('a
                                                                                     ->
                                                                                     ('a
                                                                                      ->
                                                                                      ('a
                                                                                       ->
                                                                                       ('a
                                                                                        ->
                                                                                        ('a
                                                                                         ->
                                                                                         ('a
                                                                                          ->
                                                                                          ('a
                                                                                           ->
                                                                                           ('a
                                                                                            ->
                                                                                            ('a
                                                                                             ->
                                                                                             ('a
                                                                                              ->
                                                                                              ('a
                                                                                               ->
                                                                                               ('a
                                                                                                ->
                                                                                                ('a
                                                                                                 ->
                                                                                                 ('a
                                                                                                  ->
                                                                                                  ('a
                                                                                                   ->
                                                                                                   ('a
                                                                                                    ->
                                                                                                    ('a
                                                                                                     ->
                                                                                                     ('a
                                                                                                      ->
                                                                                                      'b)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
 ->
 'c) vs. ('d
 ('d
  ->
  ('d
   ->
   ('d
    ->
    ('d
     ->
     ('d
      ->
      ('d
       ->
       ('d
        ->
        ('d
         ->
         ('d
          ->
          ('d
           ->
           ('d
            ->
            ('d
             ->
             ('d
              ->
              ('d
               ->
               ('d
                ->
                ('d
                 ->
                 ('d
                  ->
                  ('d
                   ->
                   ('d
                    ->
                    ('d
                     ->
                     ('d
                      ->
                      ('d
                       ->
                       ('d
                        ->
                        ('d
                         ->
                         ('d
                          ->
                          ('d
                           ->
                           ('d
                            ->
                            ('d
                             ->
                             ('d
                              ->
                              ('d
                               ->
                               ('d
                                ->
                                ('d
                                 ->
                                 ('d
                                  ->
                                  ('d
                                   ->
                                   ('d
                                    ->
                                    ('d
                                     ->
                                     ('d
                                      ->
                                      ('d
                                       ->
                                       ('d
                                        ->
                                        ('d
                                         ->
                                         ('d
                                          ->
                                          ('d
                                           ->
                                           ('d
                                            ->
                                            ('d
                                             ->
                                             ('d
                                              ->
                                              ('d
                                               ->
                                               ('d
                                                ->
                                                ('d
                                                 ->
                                                 ('d
                                                  ->
                                                  ('d
                                                   ->
                                                   ('d
                                                    ->
                                                    ('d
                                                     ->
                                                     ('d
                                                      ->
                                                      ('d
                                                       ->
                                                       ('d
                                                        ->
                                                        ('d
                                                         ->
                                                         ('d
                                                          ->
                                                          ('d
                                                           ->
                                                           ('d
                                                            ->
                                                            ('d
                                                             ->
                                                             ('d
                                                              ->
                                                              ('d
                                                               ->
                                                               ('d
                                                                ->
                                                                ('d
                                                                 ->
                                                                 ('d
                                                                  ->
                                                                  ('d
                                                                   ->
                                                                   ('d
                                                                    ->
                                                                    ('d
                                                                     ->
                                                                     ('d
                                                                      ->
                                                                      ('d
                                                                       ->
                                                                       ('d
                                                                        ->
                                                                        ('d
                                                                         ->
                                                                         ('d
                                                                          ->
                                                                          ('d
                                                                           ->
                                                                           ('d
                                                                            ->
                                                                            ('d
                                                                             ->
                                                                             ('d
                                                                              ->
                                                                              ('d
                                                                               ->
                                                                               ('d
                                                                                ->
                                                                                ('d
                                                                                 ->
                                                                                 ('d
                                                                                  ->
                                                                                  ('d
                                                                                   ->
                                                                                   ('d
                                                                                    ->
                                                                                    ('d
                                                                                     ->
                                                                                     ('d
                                                                                      ->
                                                                                      ('d
                                                                                       ->
                                                                                       ('d
                                                                                        ->
                                                                                        ('d
                                                                                         ->
                                                                                         ('d
                                                                                          ->
                                                                                          ('d
                                                                                           ->
                                                                                           ('d
                                                                                            ->
                                                                                            ('d
                                                                                             ->
                                                                                             ('d
                                                                                              ->
                                                                                              ('d
                                                                                               ->
                                                                                               ('d
                                                                                                ->
                                                                                                ('d
                                                                                                 ->
                                                                                                 ('d
                                                                                                  ->
                                                                                                  ('d
                                                                                                   ->
                                                                                                   ('d
                                                                                                    ->
                                                                                                    ('d
                                                                                                     ->
                                                                                                     ('d
                                                                                                      ->
                                                                                                      ('d
                                                                                                       ->
                                                                                                       'e))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
 ->
 'f)
  sources:
   f
  location...:
   test.rkt:15:9
  context...:
   /home/stites/.local/share/racket/8.10/pkgs/plait/private/types.rkt:542:0: raise-typecheck-error
   /home/stites/.local/share/racket/8.10/pkgs/plait/private/types.rkt:714:27: loop
   [repeats 2 more times]
   /home/stites/.local/share/racket/8.10/pkgs/plait/private/types.rkt:707:0: let-based-poly!
   /home/stites/.local/share/racket/8.10/pkgs/plait/main.rkt:3275:0
   /nix/store/ga24q619h10r225n60yp05c59vv6a0nj-racket-8.10/share/racket/collects/syntax/wrap-modbeg.rkt:46:4

stites avatar Jan 31 '24 20:01 stites