Skip to content

Commit

Permalink
Add use of gocode keyword to mute tuplifying returns
Browse files Browse the repository at this point in the history
  • Loading branch information
peachpit-site committed Nov 17, 2024
1 parent 23e9b7b commit 1798a15
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions source/service/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func doctorReturns(body string) string {
output := ""
for ix := strings.Index(body, "return "); ix != -1; ix = strings.Index(body, "return ") {

output = output + body[:ix] + "return tuplify("
output = output + body[:ix]

body = body[ix+7:]

Expand All @@ -305,7 +305,7 @@ func doctorReturns(body string) string {
if lineEnd == -1 {
panic("Tim, you goofed. Lines are meant to have endings.")
}
newLine := strings.TrimRight(body[:lineEnd], "\n\r \t")
newLine := strings.Trim(body[:lineEnd], "\n\r \t")
if returnBody != "" {
returnBody = returnBody + "\n"
}
Expand All @@ -321,8 +321,11 @@ func doctorReturns(body string) string {

}
body = body[ix:]
output = output + returnBody + ")"

if len(returnBody) >= 7 && returnBody[:7] == "gocode" {
output = output + "return " + returnBody
} else {
output = output + "return tuplify(" + returnBody + ")"
}
}

return output + body
Expand Down
4 changes: 2 additions & 2 deletions source/service/rsc/pipefish/world.pf
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ goGetDirectoryNames(directoryNames DirectoryNames) : gocode {
}
err := filepath.Walk(directoryNames.directory, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
return gocode err
}
if info.IsDir() {
resultList = append(resultList, info.Name())
}
return nil
return gocode nil
})
if err != nil {
return err
Expand Down

0 comments on commit 1798a15

Please sign in to comment.