Summary

foreign-lambda annotates return type without considering retconvert from define-foreign-type

Metadata

Description

 (module
  m
  *
  (import scheme
          (chicken base)
          (chicken string)
          (chicken type)
          (chicken foreign))
 
  (define-foreign-type foo int identity ->string)
 
  ;; inch gets annotated with type (procedure () fixnum) when the
  ;; return type should be whatever the retconvert argument to
  ;; define-foreign-type returns (string in this case)
  (define inch (foreign-lambda foo "rand"))
 
  (let ((v (inch)))
    (compiler-typecase v (fixnum (print (add1 (the * v)))))))
 
 =>
 ;; Error: (+) bad argument type - not a number: "92475436"
 ;;
 ;; 	Call history:
 ;;
 ;; 	ncurses.scm:3: ##sys#with-environment
 ;; 	ncurses.scm:3: ##sys#register-compiled-module
 ;; 	ncurses.scm:15: g14	  	<--

Changes and comments

[2019-12-01 01:14:49 UTC] evhan changed status from new to closed

[2019-12-01 01:14:49 UTC] evhan set resolution to fixed

[2019-12-01 01:14:49 UTC] evhan wrote:

Fixed by d6359ebf. We could be smarter about determining the right types, but the incorrect type is no longer used.