﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	difficulty
584	Unused arguments in callback wrappers are incorrectly optimized away	sjamaan	felix winkelmann	"{{{
(module bla (foo)

(import chicken scheme foreign)

(define-external
  (blabla (int a) (c-string b) (int c) (int d) (c-string e) (int f))
  void
  (print ""HELLO""))

(define (foo) ((foreign-safe-lambda* void () ""blabla(1, \""2\"", 3, 4, \""5\"", 6);"")))
)

(import bla)
(foo)
}}}

This gives an error:

{{{
Error: bad argument count - received 6 but expected 2: #<procedure>

        Call history:

        test.scm:14: bla#foo      
        ##sys#gc          
        g2728           <--
}}}

This is caused by the fact that {{{callback-names}}} contains the unqualified procedure name (not prefixed with a module name).

Attached is a patch that seems to fix this (but I'm not 100% sure if it's the Right Way(TM) of fixing this).

I think there may be other bugs like this where the raw symbol is inserted into some database while it should be using the qualified name, so it's probably a good idea to review other parts of the optimizer.

PS: The milestone 4.7.0 was reached, it should be closed in Trac and the Version dropdown should be changed to include 4.7.0"	defect	closed	critical	4.9.0	compiler	4.6.x	fixed	optimizations, define-external, ffi		
