Hi Manuel.

Manuel wrote, 2022-11-03 11:50:
> Hi Sven,
>
>> Hi.
>>
>> I am seeing new (spurious?) warnings for the current unstable version 
>> (x86_64 and x32-ABI):
>>
>> "bint" expected, "bignum" provided
>>
>> A minimal example:
>>
>> bugz11.scm:
>> ---
>> (module bugz11
>>   (export
>>    (list-ref-check::obj l pos::bint))
>>   (main main))
>>
>> (define (list-ref-check l pos)
>>   (let iter ()
>>     (if (pair? l)
>>         (cond ((= pos 0)
>>                (car l))
>>           (else
>>             (set! l (cdr l))
>>             (set! pos (- pos 1))
>>             (iter)))
>>         #f)))
>>
>> (define (main args)
>>   (let ((val (list-ref-check args 1)))
>>     (display val)
>>     (newline)
>>     0))
>> ---
>>
>>  > bigloo -O3 -ldopt "-static" -o bugz11 bugz11.scm
>>
>> File "bugz11.scm", line 14, character 370:
>> #            (set! pos (- pos 1))
>> #                      ^
>> *** WARNING: iter
>> Type error --  "bint" expected, "bignum" provided
> Actually, I think this new behavior is correct. The previous Bigloo versions
> were simply not able to detect that potential error. Let me explain.
>
> The "(- pos 1)" expression may overflow and then produce a bignum
> value. This is incompatible the "bint" type assigned to pos. I think that to
> get rid of the warning, you should use the "-fx" operator that will not
> produce a bignum value. Does this make sense to you? Do you agree that
> this new behavior is the one we should expect?

Yes, I see.

Sven

Reply via email to