Parser properly unions position of named types
This commit is contained in:
parent
6b9cdcc239
commit
159317965d
|
@ -17,6 +17,7 @@ var startTokensType = []lexer.TokenKind {
|
|||
func (this *treeParser) parseType () (entity.Type, error) {
|
||||
err := this.ExpectDesc(descriptionType, startTokensType...)
|
||||
if err != nil { return nil, err }
|
||||
pos := this.Pos()
|
||||
|
||||
switch this.Kind() {
|
||||
case lexer.Ident:
|
||||
|
@ -25,7 +26,7 @@ func (this *treeParser) parseType () (entity.Type, error) {
|
|||
if err != nil { return nil, err }
|
||||
err = this.ExpectNext(lexer.TypeIdent)
|
||||
if err != nil { return nil, err }
|
||||
return this.parseTypeNamedCore(ident)
|
||||
return this.parseTypeNamedCore(pos, ident)
|
||||
|
||||
case lexer.TypeIdent:
|
||||
if this.Value() == "Int" || this.Value() == "UInt" {
|
||||
|
@ -46,7 +47,7 @@ func (this *treeParser) parseType () (entity.Type, error) {
|
|||
}
|
||||
}
|
||||
|
||||
return this.parseTypeNamedCore("")
|
||||
return this.parseTypeNamedCore(pos, "")
|
||||
|
||||
case lexer.Star:
|
||||
return this.parseTypePointerOrSlice()
|
||||
|
@ -69,13 +70,13 @@ func (this *treeParser) parseType () (entity.Type, error) {
|
|||
panic(this.bug())
|
||||
}
|
||||
|
||||
func (this *treeParser) parseTypeNamedCore (unitNickname string) (entity.Type, error) {
|
||||
func (this *treeParser) parseTypeNamedCore (pos errors.Position, unitNickname string) (entity.Type, error) {
|
||||
err := this.Expect(lexer.TypeIdent)
|
||||
if err != nil { return nil, err }
|
||||
|
||||
defer this.Next()
|
||||
return &entity.TypeNamed {
|
||||
Position: this.Pos(),
|
||||
Position: pos.Union(this.Pos()),
|
||||
Name: this.Value(),
|
||||
UnitNickname: unitNickname,
|
||||
}, nil
|
||||
|
|
Loading…
Reference in New Issue