You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class MyInt {
var x:int;
}
use Map;
var myMap =new map(string, owned MyInt);
# chpl version 1.21.0 pre-release (8b3bca92)
$CHPL_HOME/modules/standard/Map.chpl:96: In function 'init=':
$CHPL_HOME/modules/standard/Map.chpl:105: error: illegal lvalue in assignment
Also, I'm certain the remove function won't work either since I tried something similar on a bare associative array.
The text was updated successfully, but these errors were encountered:
The reported behavior seems specific to the value type being an owned type. Making it a shared or unmanaged class makes the code above work. That said, I think there are other problems with non-nilable element types and maps, related to issue #14367 (i.e., I think the current map implementation works for cases like map(string, shared MyInt) today because of #14367, where it would stop working if/when #14367 was fixed).
The thing that is causing this error is that the init= function takes its argument by const ref intent. Then it assigns all of the values (in this case none) in the rhs map to the lhs map, which for an owned class type modifies the const rhs to set the values to nil.
Changing the argument to use ref gets rid of the error by allowing the rhs to be modified.
Bug.
map
doesn't work when value type is a class.Also, I'm certain the
remove
function won't work either since I tried something similar on a bare associative array.The text was updated successfully, but these errors were encountered: