Index: src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java =================================================================== --- src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java (revision 19149) +++ src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java (working copy) @@ -4323,6 +4323,11 @@ return value; } + public static V putAt(Map self, String key, V value) { + self.put(key, value); + return value; + } + /** * Support the subscript operator for List *
assert [String, Long, Integer] == ["a",5L,2]["class"]
Index: src/test/groovy/bugs/Groovy4029Bug.groovy =================================================================== --- src/test/groovy/bugs/Groovy4029Bug.groovy (revision 0) +++ src/test/groovy/bugs/Groovy4029Bug.groovy (revision 0) @@ -0,0 +1,9 @@ +package groovy.bugs + +class Groovy4029Bug extends GroovyTestCase { + void testAddNullKeyEntryInMapUsingSubscriptNotation() { + Map m = [:] + m[null] = null + assert m.size() == 1 + } +}