#2279 Case insensitive maps

SlimerDude Tue 6 May 2014

If I try to set the case-insensitivity of an empty map to false I get:

[:] { caseInsensitive = false }

sys::UnsupportedErr: Map not keyed by Str: [sys::Obj:sys::Obj?]
  fan.sys.Map.caseInsensitive (Map.java:251)

Could the Err check take into account the value that's being set?

Map.java:251
if (type.k != Sys.StrType && v)  // <-- && v
  throw UnsupportedErr.make("Map not keyed by Str: " + type);

I'm creating Maps programmatically so caseInsensitive is a variable, I'm not setting it explicitly.

(My current workaround is to use an if statement to explicitly create the 2 different types of maps.)

SlimerDude Tue 6 May 2014

Interesting! As a side note, I can create maps with nullable keys!

Map.make(Map#.parameterize(["K":Int?#, "V":Obj?#])).typeof.signature

--> [sys::Int?:sys::Obj?]

Not that I can do anything with it, as all the Map method signatures require non-null keys.

brian Tue 6 May 2014

If I try to set the case-insensitivity of an empty map to false I get:

It seems better to be strict here and say that calling that setter really should only be if the key is a string type.

Interesting! As a side note, I can create maps with nullable keys!

That definitely seems like a bug to me! I pushed a fix and added some tests

SlimerDude Wed 7 May 2014

calling that setter really should only be if the key is a string type.

The value can only be true if the key is a string type, yes.

But being thrown an Err for calling a simple setter with a valid value (the same value that it is currently!) is unexpected behaviour - and certainly nothing that any code should be relying on!

It seems better to be strict here

Maybe, but it's not helping me! :p But that indicated 4 character fix would though!

I can create maps with nullable keys! > That definitely seems like a bug to me! I pushed a fix

Oh, okay! I didn't see that as a problem myself! :)

Login or Signup to reply.