shithub: mc

Download patch

ref: d42ef53f3c986c1999a7e4cba96f75f4a8137fc9
parent: 605f963ab132456ca911d18000164399ea661aca
author: Ori Bernstein <[email protected]>
date: Mon Aug 6 20:25:41 EDT 2012

Improve commenting

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -930,6 +930,7 @@
 
         found = 0;
         t = tybase(tf(st, type(st, aggr)));
+        /* all array-like types have a fake "len" member that we emulate */
         if (t->type == Tyslice || t->type == Tyarray) {
             if (!strcmp(namestr(memb), "len")) {
                 constrain(st, n, type(st, n), cstrtab[Tcnum]);
@@ -937,6 +938,13 @@
                 constrain(st, n, type(st, n), cstrtab[Tctest]);
                 found = 1;
             }
+        /* otherwise, we search aggregate types for the member, and unify
+         * the expression with the member type; ie:
+         *
+         *     x: aggrtype    y : memb in aggrtype
+         *     ---------------------------------------
+         *               x.y : membtype
+         */
         } else {
             if (t->type == Typtr)
                 t = tybase(tf(st, t->sub[0]));