Summary

Type information doesn't survive calls to define-inline procedures

Metadata

Description

Compile the following to C:

 (module foo ()
   (import scheme (chicken base) (chicken plist))
 
   (let ((x (gensym)))
     (put! 'foo x 1))
 
   (define-inline (put-one! sym prop)
     (put! sym prop 1))
 
   (let ((y (gensym)))
     (put-one! 'foo y)))

Note that the first call to put! gets rewritten to C_a_i_putprop(&a,3,lf[[1]|],t1,C_fix(1)), but the second call remains a CPS call to chicken.plist#put! via procedure lookup.

This is unexpected, as inlining by hand should give the same results as calling a define-inline procedure.

If you restore the typing info by hand, it also works as expected:

 (define-inline (put-one! sym prop)
   (put! (the symbol sym) (the symbol prop) 1))

Changes and comments

[2025-08-20 09:03:21 UTC] sjamaan wrote:

BTW, it's also a bit strange that the types can't be determined for procedures that get contracted or inlined by the compiler when using regular define.