Skip to content

Commit

Permalink
Fix type when indexing Go string.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed Oct 16, 2022
1 parent f05df98 commit cfc1ca8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions c_expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,13 @@ func (e *CParentExpr) Uses() []types.Usage {

func (g *translator) NewCIndexExpr(x, ind Expr, typ types.Type) Expr {
ind = cUnwrap(ind)
if types.Same(x.CType(nil), g.env.Go().String()) {
return &CIndexExpr{
ctype: g.env.Go().Byte(),
Expr: x,
Index: ind,
}
}
if addr, ok := cUnwrap(x).(*TakeAddr); ok {
if ind2, ok := addr.X.(*CIndexExpr); ok {
// add another component to the index expr
Expand Down

0 comments on commit cfc1ca8

Please sign in to comment.