From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 61004 invoked by alias); 1 Jan 2017 18:19:41 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 60990 invoked by uid 89); 1 Jan 2017 18:19:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=accuracy, Shouldnt, Shouldn't, iota X-HELO: aibo.runbox.com Received: from aibo.runbox.com (HELO aibo.runbox.com) (91.220.196.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 01 Jan 2017 18:19:30 +0000 Received: from [10.9.9.211] (helo=mailfront11.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1cNkj9-0000rt-8U; Sun, 01 Jan 2017 19:19:27 +0100 Received: from 70-36-239-8.dsl.dynamic.fusionbroadband.com ([70.36.239.8] helo=localhost.localdomain) by mailfront11.runbox.com with esmtpsa (uid:757155 ) (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) id 1cNkj3-0006fk-OK; Sun, 01 Jan 2017 19:19:22 +0100 Subject: Re: Reflection on function argument types To: Duncan Mak , kawa mailing list References: From: Per Bothner Message-ID: <10f01de4-d72f-799c-795c-9a078ebfa239@bothner.com> Date: Sun, 01 Jan 2017 18:19:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-q1/txt/msg00000.txt.bz2 On 12/27/2016 09:34 PM, Duncan Mak wrote: > I wrote the following code: > > (import (srfi 1)) > (define (foo (a :: integer)) (+ a a)) > (define (hello-number (n :: number) (i :: number)) (list "number" n)) > (define (hello-string (s :: string)) (list "string" s)) > (define (print-types (func :: gnu.mapping.MethodProc)) > (display (procedure-property func 'name)) (newline) > (for-each (lambda (t) (display t) (newline)) > (map (lambda (i) (func:getParameterType i)) (iota > (func:numParameters)))) > (newline)) > (print-types foo) > (print-types hello-number) > (print-types hello-string) > > I'm surprise to see that the output differs between foo and hello-*: > > foo > Type integer > > hello-number > ClassType java.lang.Object > ClassType java.lang.Object > > hello-string > ClassType java.lang.Object > > Why is it that I only see java.lang.Object for the hello-* functions? > Shouldn't number and string show up, like it did for foo? This turns out to be a problem with demangling. 'foo' works because it doesn't have any special characters. In ModuleMethod.java in resolveParameterTypes it says: String mangledName = Mangling.mangleNameIfNeeded(name); but it should be: String mangledName = Mangling.mangleName(name); Unfortunately, fixing this improves the accuracy of type-checking enough to cause some problems. For example this code (simplified from r7rs-tests.scm): (let ((val 'abc)) (cond ((and (complex? val) (not (nan? val))) (display val)))) Kawa complains that the call to nan? is invalid because the argument val is a symbol. This is bogus, since the previous test to complex? ensures nan? is never called. I created this issue: https://gitlab.com/kashell/Kawa/issues/1 -- --Per Bothner per@bothner.com http://per.bothner.com/