Summary

At higher optimization levels, some scrutiny warnings disappear

Metadata

Description

 #!scheme
 (use data-structures)
 (print (sort '(x y z) (lambda (a b) (> a b))))

When compiled with -O2 or lower, this gives the warning:

 Warning: at toplevel:
   (/tmp/test.scm:5) in procedure call to `sort',
   expected argument #2 of type `(procedure (symbol symbol) *)'
   but was given an argument of type `(procedure (number number) boolean)'

When compiled with -O3 or higher, no output is given.

The warning is always shown in master, as far as I can tell.

Changes and comments

[2016-08-25 20:30:00 UTC] sjamaan set difficulty to hard

[2017-02-28 20:34:47 UTC] sjamaan wrote:

As pointed out by TheLemonMan, this is caused by the rewrite for > that was introduced by c493d5100. The diff is:

 -   ((number number) (##core#inline "C_i_greaterp" #(1) #(2))))
 +   ((* *) (##core#inline "C_i_greaterp" #(1) #(2))))

Apparently the rewrite happens so early that the scrutinizer has no opportunity to detect that the argument to sort is wrong.

The rewrite itself seems correct to me, because it is more efficient than rewriting only numbers, if the compiler doesn't know the types (C_i_greaterp will raise a runtime error if it is passed non-numbers).

[2017-03-01 00:20:02 UTC] evhan changed priority from major to minor

[2017-03-01 00:20:02 UTC] evhan changed version from 4.10.x to 5.0

[2017-11-23 10:56:23 UTC] felix changed milestone from 5.0 to 5.1

[2019-04-07 12:23:24 UTC] sjamaan changed milestone from 5.1 to 5.2

[2019-04-07 12:23:24 UTC] sjamaan wrote:

Getting ready for 5.1, moving tickets which won't make it in to 5.2.

[2019-08-25 17:45:37 UTC] felix changed status from new to closed

[2019-08-25 17:45:37 UTC] felix set resolution to fixed

[2019-08-25 17:45:37 UTC] felix wrote:

Commit bc72c05fa61581fc1fa86e90000a002847c3f28b removed the generalization in types.db.