Summary

Rest-argument optimization related internal compiler error

Metadata

Description

mdg extension is in brev egg and also depends on match-generics egg

(import  mdg (chicken base))

(define (pairup lis) lis)

(define (pairup (a b . rest))
  (cons (list a b) (pairup rest)))

(print (pairup '(a b c d e f g h)))
; on -O2, prints ((a b) (c d) (e f) (g h))
; on -O3, Error
compiler error Unknown rest op node class in while converting to closure. This shouldn't happen!: ##core#rest-null?

Changes and comments

[2021-05-28 19:20:41 UTC] megane wrote:

Somewhat reduced:

 (set! pairup
     (lambda args
       (let ((ren args))
         (let ((fail
                (lambda ()
                  (if (pair? ren)
                      (null? (cdr ren))))))
           (if (pair? ren)
               1
               (fail))))))

[2021-05-28 19:45:07 UTC] Idiomdrottning wrote:

That doesn't crash for me though.

[2021-05-28 20:18:05 UTC] megane wrote:

Replying to Idiomdrottning: > That doesn't crash for me though.

Interesting. What options, csc version is that?

I'm using -O3 and Version 5.2.1 (rev ea32b1d0).

[2021-05-28 20:20:15 UTC] megane set keywords to optimizer

[2021-05-28 20:20:15 UTC] megane changed milestone from someday to 5.3

[2021-05-28 20:20:15 UTC] megane changed component from unknown to compiler

[2021-05-28 20:20:15 UTC] megane changed summary

[2021-05-29 09:53:35 UTC] Idiomdrottning wrote:

ellen% csc -version
csc -version
CHICKEN
(c) 2008-2020, The CHICKEN Team
(c) 2000-2007, Felix L. Winkelmann
Version 5.2.0 (rev 317468e4)
linux-unix-gnu-x86-64 [[|64bit dload ptables ]]

[2021-05-29 09:55:10 UTC] Idiomdrottning wrote:

-O3, no -d flags

[2021-05-29 12:36:56 UTC] felix wrote:

This was just a typo. Patch pending:

  core.scm | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/core.scm b/core.scm
 index 85ccc649..5ca76d1d 100644
 --- a/core.scm
 +++ b/core.scm
 @@ -2668,7 +2668,7 @@
  		       (transform (make-node '##core#inline
  					     (list "C_i_list_ref")
  					     (list rest-var (qnode (second params)))) here closure))
 -		      ((##core#rest-null)
 +		      ((##core#rest-null?)
  		       (transform (make-node '##core#inline
  					     (list "C_i_greater_or_equal_p")

[2021-05-29 12:37:04 UTC] felix changed status from new to closed

[2021-05-29 12:37:04 UTC] felix set resolution to fixed