Skip to content

Commit 0308c92

Browse files
kyegupovaykevl
authored andcommitted
compiler: better error message on trying to do a map lookup using an unsupported type
1 parent 1db9a16 commit 0308c92

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

compiler/map.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (c *Compiler) emitMapLookup(keyType, valueType types.Type, m, key llvm.Valu
2929
params := []llvm.Value{m, keyPtr, mapValuePtr}
3030
commaOkValue = c.createRuntimeCall("hashmapBinaryGet", params, "")
3131
} else {
32-
return llvm.Value{}, c.makeError(pos, "todo: map lookup key type: "+keyType.String())
32+
return llvm.Value{}, c.makeError(pos, "only strings, bools, ints or structs of bools/ints are supported as map keys, but got: "+keyType.String())
3333
}
3434
mapValue := c.builder.CreateLoad(mapValueAlloca, "")
3535
if commaOk {
@@ -61,7 +61,7 @@ func (c *Compiler) emitMapUpdate(keyType types.Type, m, key, value llvm.Value, p
6161
c.createRuntimeCall("hashmapBinarySet", params, "")
6262
return nil
6363
} else {
64-
return c.makeError(pos, "todo: map update key type: "+keyType.String())
64+
return c.makeError(pos, "only strings, bools, ints or structs of bools/ints are supported as map keys, but got: "+keyType.String())
6565
}
6666
}
6767

@@ -80,7 +80,7 @@ func (c *Compiler) emitMapDelete(keyType types.Type, m, key llvm.Value, pos toke
8080
c.createRuntimeCall("hashmapBinaryDelete", params, "")
8181
return nil
8282
} else {
83-
return c.makeError(pos, "todo: map delete key type: "+keyType.String())
83+
return c.makeError(pos, "only strings, bools, ints or structs of bools/ints are supported as map keys, but got: "+keyType.String())
8484
}
8585
}
8686

0 commit comments

Comments
 (0)