Opened 4 weeks ago

#1649 new defect

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

Reported by: megane Owned by:
Priority: major Milestone: 5.2
Component: scrutinizer Version: 5.1.0
Keywords: Cc:
Estimated difficulty: medium

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	  	<--

Change History (0)

Note: See TracTickets for help on using tickets.