Skip to content

Commit

Permalink
Type check insertvalue operands
Browse files Browse the repository at this point in the history
  • Loading branch information
pwaller committed Feb 23, 2019
1 parent d51964f commit 47f6d07
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ir/inst_aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ type InstInsertValue struct {
// NewInsertValue returns a new insertvalue instruction based on the given
// aggregate value, element and indicies.
func NewInsertValue(x, elem value.Value, indices ...uint64) *InstInsertValue {
elemType := aggregateElemType(x.Type(), indices)
if !elemType.Equal(elem.Type()) {
panic(fmt.Errorf("insertvalue elem type mismatch, got %v, want %v", elem.Type(), elemType))
}
inst := &InstInsertValue{X: x, Elem: elem, Indices: indices}
// Compute type.
return inst
Expand Down

0 comments on commit 47f6d07

Please sign in to comment.