diff options
| author | Robert Griesemer <gri@golang.org> | 2009-01-14 15:19:34 -0800 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2009-01-14 15:19:34 -0800 |
| commit | 50c0662801b3240e83b4bdee4bd400128b519ac6 (patch) | |
| tree | bf88ddb72925d00e8b97b89d8e27aa0ffb113d3a /usr/gri/pretty/parser.go | |
| parent | 927157595edc2e3cc57951187b7a0d5901f609b5 (diff) | |
| download | golang-50c0662801b3240e83b4bdee4bd400128b519ac6.tar.gz | |
- use new letter definition for pretty
- fixed a bug with error column reporting in the presence of utf-8 chars
- fixed an assertion failure
R=r
OCL=22762
CL=22762
Diffstat (limited to 'usr/gri/pretty/parser.go')
| -rw-r--r-- | usr/gri/pretty/parser.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/usr/gri/pretty/parser.go b/usr/gri/pretty/parser.go index eaadf105a..4ae58504c 100644 --- a/usr/gri/pretty/parser.go +++ b/usr/gri/pretty/parser.go @@ -167,15 +167,17 @@ func (P *Parser) DeclareInScope(scope *AST.Scope, x *AST.Expr, kind int) { if P.scope_lev < 0 { panic("cannot declare objects in other packages"); } - obj := x.obj; - assert(x.tok == Scanner.IDENT && obj.kind == AST.NONE); - obj.kind = kind; - obj.pnolev = P.scope_lev; - if scope.LookupLocal(obj.ident) != nil { - P.Error(obj.pos, `"` + obj.ident + `" is declared already`); - return; // don't insert it into the scope - } - scope.Insert(obj); + if x.tok != Scanner.ILLEGAL { // ignore bad exprs + obj := x.obj; + assert(x.tok == Scanner.IDENT && obj.kind == AST.NONE); + obj.kind = kind; + obj.pnolev = P.scope_lev; + if scope.LookupLocal(obj.ident) != nil { + P.Error(obj.pos, `"` + obj.ident + `" is declared already`); + return; // don't insert it into the scope + } + scope.Insert(obj); + } } |
