bugKawa - Bugs: bug #42722, Explicit type declaration, later...

 
 

bug #42722: Explicit type declaration, later instance? check issues

Submitter:  None
Submitted:  Thu 10 Jul 2014 04:30:44 AM UTC
   
 
Category:  Type declaration and inference Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  bothner
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 31 Jul 2014 02:51:55 PM UTC, comment #2: 

I checked in a fix for this.

Per Bothner <bothner>
Group administrator
Thu 10 Jul 2014 05:39:00 PM UTC, comment #1: 

This is a gray area: The type 'String' is a special type in that every value is compatible with it: a non-null value x is converted to the String type by calling x.toString().

Instead, you might want to use:
  (instance? v1 string) ;; lower-case string type
or:
  (instance? v1 java.lang.CharSequence)
or:
  (instance? v1 java.lang.String)

The type string is equivalent to java.lang.CharSequence.

Back to the String type: even if every value is convertible to String, it is probably not correct to say (instance? v1 String).  As you've noticed there some inconsistencies in this result, if v1 is a more complex expression.  There does seem to be a bug.

Per Bothner <bothner>
Group administrator
Thu 10 Jul 2014 04:30:44 AM UTC, original submission:  

I am using Kawa Scheme 1.14 downloaded as JAR from the ftp server.
Try the following:

(define v1 ::int 0)
(instance? v1 String)

This returns #t, whereas I expected #f. Maybe I am understanding the language semantics wrong?

(define v2 (+ v1 2))
(instance? v2 String)

This returns #f as expected.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bothner (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-07-31 bothner StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2014-07-10 bothner StatusNone Confirmed
        Assigned toNone bothner

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code