shithub: mc

Download patch

ref: e25ab2a93db2cff8ee634e0f82244a66137279ba
parent: 14b5372a6e42135957bf8f229a6f890b2edfdf4b
author: Ori Bernstein <[email protected]>
date: Wed Apr 29 17:07:18 EDT 2015

Resolve the type on array indexes.

    If we never used the type, we never resolved it, which means
    we never set the type on the literal. This can cause some
    potential type errors.

    This resolves the type when doing the substitutions, in case
    we didn't already get to it.

--- a/parse/gram.y
+++ b/parse/gram.y
@@ -467,7 +467,10 @@
 compoundtype
         : functype   {$$ = $1;}
         | type Tosqbrac Tcolon Tcsqbrac {$$ = mktyslice($2->loc, $1);}
-        | type Tosqbrac expr Tcsqbrac {$$ = mktyarray($2->loc, $1, $3);}
+        | type Tosqbrac expr Tcsqbrac {
+                $3->expr.type = mktype($3->loc, Tyuint32);
+                $$ = mktyarray($2->loc, $1, $3);
+            }
         | type Tosqbrac Tellipsis Tcsqbrac {$$ = mktyarray($2->loc, $1, NULL);}
         | type Tderef {$$ = mktyptr($2->loc, $1);}
         | Tat Tident {$$ = mktyparam($1->loc, $2->id);}