From a651946900c4cd857dc654104fc9b217db89ff17 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Fri, 12 May 2017 11:13:36 +1000 Subject: [PATCH] Add some comments. --- lang/check/check.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lang/check/check.go b/lang/check/check.go index 12590099..5cbfb4ec 100644 --- a/lang/check/check.go +++ b/lang/check/check.go @@ -116,16 +116,25 @@ func (c *Checker) checkFuncBody(n *a.Node) error { idMap: c.idMap, typeMap: c.funcs[f.QID()].LocalVars, } + + // Fill in the TypeMap with all local variables. Note that they have + // function scope and can be hoisted, JavaScript style, a la + // https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/var for _, m := range f.Body() { if err := tc.checkVars(m); err != nil { return fmt.Errorf("%v at %s:%d", err, m.Raw().Filename(), m.Raw().Line()) } } + + // Assign ConstValue's (if applicable) and MType's to each Expr. for _, m := range f.Body() { if err := tc.checkStatement(m); err != nil { return fmt.Errorf("%v at %s:%d", err, m.Raw().Filename(), m.Raw().Line()) } } + + // TODO: bounds and assertion checking. + return nil }