chicken-janitors
[Top][All Lists]
Advanced

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

[Chicken-janitors] #1471: [types] Enforce parameter types on specializat


From: Chicken Trac
Subject: [Chicken-janitors] #1471: [types] Enforce parameter types on specialization
Date: Wed, 06 Jun 2018 07:02:43 -0000

#1471: [types] Enforce parameter types on specialization
-------------------------------+--------------------------------
 Reporter:  megane             |                 Owner:
     Type:  enhancement        |                Status:  new
 Priority:  not urgent at all  |             Milestone:  someday
Component:  scrutinizer        |               Version:  5.0
 Keywords:                     |  Estimated difficulty:  medium
-------------------------------+--------------------------------
 Currently no enforcing happens if specialization takes place.

 Here's a case from scrutiny-tests.
 Note that scheme#+ has a specialization for parameters (* *).
 When using `-A` flag no specialization takes place, so the enforcing
 happens.

 In this example you'd like to have the type for `x` to be enforced to
 `number` after the `if`.

 {{{
 ;; noreturn conditional branch enforces "number" on x
 (define (foo2 x)
   (if (string? x) (error "foo") (+ x 3))
   (string-append x "abc"))

 ;; $ csc -O3 enforce-fail.scm
 ;;
 ;; Warning: in toplevel procedure `foo2':
 ;;   (enforce-fail.scm:7) in procedure call to `scheme#string-append',
 expected argument #1 of type `string' but was given an argument of type
 `(not string)'

 ;; $ csc -A enforce-fail.scm
 ;;
 ;; Warning: in toplevel procedure `foo2':
 ;;   (enforce-fail.scm:7) in procedure call to `scheme#string-append',
 expected argument #1 of type `string' but was given an argument of type
 `number'
 }}}

--
Ticket URL: <https://bugs.call-cc.org/ticket/1471>
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]