compiler: fix binops on named types in struct fields

Этот коммит содержится в:
Ayke van Laethem 2018-11-24 22:13:01 +01:00
родитель dbb3211485
коммит f0fb1bd41a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E97FF5335DFDFDED
2 изменённых файлов: 5 добавлений и 3 удалений

Просмотреть файл

@ -2225,7 +2225,7 @@ func (c *Compiler) parseExpr(frame *Frame, expr ssa.Value) (llvm.Value, error) {
if err != nil {
return llvm.Value{}, err
}
return c.parseBinOp(expr.Op, expr.X.Type().Underlying(), x, y)
return c.parseBinOp(expr.Op, expr.X.Type(), x, y)
case *ssa.Call:
// Passing the current task here to the subroutine. It is only used when
// the subroutine is blocking.
@ -2711,7 +2711,7 @@ func (c *Compiler) parseExpr(frame *Frame, expr ssa.Value) (llvm.Value, error) {
}
func (c *Compiler) parseBinOp(op token.Token, typ types.Type, x, y llvm.Value) (llvm.Value, error) {
switch typ := typ.(type) {
switch typ := typ.Underlying().(type) {
case *types.Basic:
if typ.Info()&types.IsInteger != 0 {
// Operations on integers

4
testdata/binop.go предоставленный
Просмотреть файл

@ -58,8 +58,10 @@ var s2 = Struct2{"foo", 0.0, 5}
var a1 = [2]int{1, 2}
type Int int
type Struct1 struct {
i int
i Int
b bool
}