chicken-janitors
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-janitors] #1481: compiler type warning (but no need for a warni


From: Chicken Trac
Subject: [Chicken-janitors] #1481: compiler type warning (but no need for a warning)
Date: Sat, 30 Jun 2018 23:05:10 -0000

#1481: compiler type warning (but no need for a warning)
------------------------------+--------------------------------
 Reporter:  snoewchen         |                 Owner:
     Type:  defect            |                Status:  new
 Priority:  minor             |             Milestone:  someday
Component:  compiler          |               Version:  4.13.0
 Keywords:  compiler warning  |  Estimated difficulty:
------------------------------+--------------------------------
 In the attached file there are 3 versions of a procedure "assq-val" that
 returns the associated value to a given key.

 The procedure distinguishes if "assq" found really just a pair or a list,
 so that
 {{{
   (assq-val 'a '((a . "b"))) => "b" ; obviously
   (assq-val 'a '((a "b)) => "b" ; instead of '("b")
 }}}

 You can find 3 Variants in the file (all 3 variants should be semantically
 equal):

   a) assq-val-no-warning
   b) assq-val-warning
   c) assq-val-also-no-warning

 The strange thing is that the compiler says (for version (b) "assq-val-
 warning")

 {{{
 Warning: in toplevel procedure `assq-val-warning':
   (...:21) in procedure call to `cdr', expected argument #1
   of type `pair' but was given an argument of type `false'
 }}}

 The call "(cdr el)" is in the if-branch of "(if (pair? el)" - so no risk
 for "el" to be #f.

 What's even more perplexing - version (c) of "assq-val" is the same as
 version (b) - just the "let"-form of version (b) is replaced by a "define"
 - and with that change the compiler warning goes away.

 (I discovered the warning the other way around actually - beeing a scheme
 rookie the first version had the "define" form (more beginner friendly
 because less parens) - after some days of hacking I replaced the
 "define"-form with let - and boom - compiler warning.)

 My chicken version:
 {{{
 (c) 2008-2017, The CHICKEN Team
 (c) 2000-2007, Felix L. Winkelmann
 Version 4.13.0 (rev 68eeaaef)
 linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
 compiled 2017-12-11 on yves.more-magic.net (Linux)
 }}}

--
Ticket URL: <https://bugs.call-cc.org/ticket/1481>
CHICKEN Scheme <https://www.call-cc.org/>
CHICKEN Scheme is a compiler for the Scheme programming language.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]