aboutsummaryrefslogtreecommitdiffhomepage
path: root/compiler/map.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2019-04-21 16:20:25 +0200
committerRon Evans <[email protected]>2019-04-26 08:52:10 +0200
commitd155e31b64b67305058ce9710912e6ca0d22a2a4 (patch)
tree943dbf419e27c99c1c3318907dd241ef6e33f30b /compiler/map.go
parent45cacda7b343ad50c4caa9718dfd9bf46bc491ab (diff)
downloadtinygo-d155e31b64b67305058ce9710912e6ca0d22a2a4.tar.gz
tinygo-d155e31b64b67305058ce9710912e6ca0d22a2a4.zip
all: improve compiler error handling
Most of these errors are actually "todo" or "unimplemented" errors, so the return type is known. This means that compilation can proceed (with errors) even though the output will be incorrect. This is useful because this way, all errors in a compilation unit can be shown together to the user.
Diffstat (limited to 'compiler/map.go')
-rw-r--r--compiler/map.go6
1 files changed, 2 insertions, 4 deletions
diff --git a/compiler/map.go b/compiler/map.go
index f8531191a..e69393c22 100644
--- a/compiler/map.go
+++ b/compiler/map.go
@@ -39,7 +39,7 @@ func (c *Compiler) emitMapLookup(keyType, valueType types.Type, m, key llvm.Valu
}
}
-func (c *Compiler) emitMapUpdate(keyType types.Type, m, key, value llvm.Value, pos token.Pos) error {
+func (c *Compiler) emitMapUpdate(keyType types.Type, m, key, value llvm.Value, pos token.Pos) {
valueAlloca := c.builder.CreateAlloca(value.Type(), "hashmap.value")
c.builder.CreateStore(value, valueAlloca)
valuePtr := c.builder.CreateBitCast(valueAlloca, c.i8ptrType, "hashmap.valueptr")
@@ -48,7 +48,6 @@ func (c *Compiler) emitMapUpdate(keyType types.Type, m, key, value llvm.Value, p
// key is a string
params := []llvm.Value{m, key, valuePtr}
c.createRuntimeCall("hashmapStringSet", params, "")
- return nil
} else if hashmapIsBinaryKey(keyType) {
// key can be compared with runtime.memequal
keyAlloca := c.builder.CreateAlloca(key.Type(), "hashmap.key")
@@ -56,9 +55,8 @@ func (c *Compiler) emitMapUpdate(keyType types.Type, m, key, value llvm.Value, p
keyPtr := c.builder.CreateBitCast(keyAlloca, c.i8ptrType, "hashmap.keyptr")
params := []llvm.Value{m, keyPtr, valuePtr}
c.createRuntimeCall("hashmapBinarySet", params, "")
- return nil
} else {
- return c.makeError(pos, "only strings, bools, ints or structs of bools/ints are supported as map keys, but got: "+keyType.String())
+ c.addError(pos, "only strings, bools, ints or structs of bools/ints are supported as map keys, but got: "+keyType.String())
}
}