Skip to content

x/pkgsite: so bueatifull goto syntax for parse text but compile error #70569

Closed as not planned

Description

@epowsal

What is the URL of the page with the issue?

no

What is your user agent?

no

Screenshot

no

What did you do?

func (de *Describle) ParseLi() bool {
var tw []byte
i := 0

tw = de.li[i:i]
for ; i < len(de.li) && de.li[i] == '\t'; i += 1 {
	tw = append(tw, de.li[i])
}
ss := NewSimpleSentence(tw)
de.ss = append(de.ss, ss)
tw = tw[:0]

jump:
if i < len(de.li) {
switch de.li[i] {
case '"':
goto biquote
case ''':
goto singlequote
case ':':
goto colon
case ';':
goto semicolon
default:
goto other
}
} else {
goto end
}

semicolon:
if len(tw) > 0 {
ss := NewSimpleSentence(tw)
de.ss = append(de.ss, ss)
}
i += 1
tw = de.li[i:i]
for ; i < len(de.li) && !(de.li[i] == '"' || de.li[i] == ''' || de.li[i] == ':' || de.li[i] == ';'); i += 1 {
tw = append(tw, de.li[i])
}
goto jump

colon:
if len(tw) > 0 {
ss := NewSimpleSentence(tw)
de.ss = append(de.ss, ss)
}
tw = de.li[i:i]
for ; i < len(de.li) && de.li[i] == ':'; i += 1 {
tw = append(tw, de.li[i])
}
ss := NewSimpleSentence(tw)
de.ss = append(de.ss, ss)
tw = de.li[i:i]
goto jump

biquote:
bqs := de.li[i]
var bqs1 byte
if i+1 < len(de.li) && de.li[i+1] == '"' {
bqs1 = de.li[i+1]
tw = append(tw, de.li[i])
i += 1
}
tw = append(tw, de.li[i])
i += 1
for ; i < len(de.li); i += 1 {
switch de.li[i] {
case bqs:
if bqs1 == 0 {
tw = append(tw, de.li[i])
i += 1
goto jump
} else {
if i+1 < len(de.li) && de.li[i+1] == '"' {
tw = append(tw, de.li[i])
tw = append(tw, de.li[i+1])
i += 2
goto jump
} else {
tw = append(tw, de.li[i])
}
}
default:
tw = append(tw, de.li[i])
}
}
goto jump

singlequote:
sqs := de.li[i]
var sqs1 byte
if i+1 < len(de.li) && de.li[i+1] == ''' {
sqs1 = de.li[i+1]
tw = append(tw, de.li[i])
i += 1
}
tw = append(tw, de.li[i])
i += 1
for ; i < len(de.li); i += 1 {
switch de.li[i] {
case sqs:
if sqs1 == 0 {
tw = append(tw, de.li[i])
i += 1
goto jump
} else {
if i+1 < len(de.li) && de.li[i+1] == ''' {
tw = append(tw, de.li[i])
tw = append(tw, de.li[i+1])
i += 2
goto jump
} else {
tw = append(tw, de.li[i])
}
}
default:
tw = append(tw, de.li[i])
}
}
goto jump

other:
for ; i < len(de.li) && !(de.li[i] == '"' || de.li[i] == ''' || de.li[i] == ':' || de.li[i] == ';'); i += 1 {
tw = append(tw, de.li[i])
}
goto jump

end:
if le(tw) > 0 {
ss := NewSimpleSentence(tw)
de.ss = append(de.ss, ss)
}

de.parsewg.Done()
return false

}

What did you see happen?

.\diskpoda_ai_describle.go:67:9: goto biquote jumps over declaration of ss at .\diskpoda_ai_describle.go:102:5
.\diskpoda_ai_describle.go:69:9: goto singlequote jumps over declaration of bqs1 at .\diskpoda_ai_describle.go:109:6

but ss is in block.it should compile pass theough.
bqs1 is right positionn should compile pass thorough.

What did you expect to see?

compile pass through

Activity

  1. added this to the Unreleased milestone on Nov 26, 2024
  2. gabyhelp commented on Nov 26, 2024

    @gabyhelp
  3. seankhliao commented on Nov 26, 2024

    @seankhliao
    Member

    Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

    For questions please refer to https://github.com/golang/go/wiki/Questions

  4. locked as spam and limited conversation to collaborators on Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions