Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't do a full camel case check against exported verbs #1791

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions go-runtime/compile/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import (
"unicode"
"unicode/utf8"

"github.com/TBD54566975/ftl/go-runtime/schema/analyzers"
"github.com/alecthomas/types/optional"
"golang.org/x/exp/maps"

"github.com/TBD54566975/ftl/go-runtime/schema/analyzers"

"github.com/TBD54566975/ftl/backend/schema"
"github.com/TBD54566975/ftl/backend/schema/strcase"
"github.com/TBD54566975/ftl/internal/goast"
Expand Down Expand Up @@ -1224,8 +1225,8 @@ func visitFuncDecl(pctx *parseContext, node *ast.FuncDecl) (verb *schema.Verb) {
return nil
}

if expVerbName := strcase.ToUpperCamel(node.Name.Name); node.Name.Name != expVerbName {
pctx.errors.add(errorf(node, "unexpected verb name %q, did you mean to use %q instead?", node.Name.Name, expVerbName))
if expName := exportedName(node.Name.Name); node.Name.Name != expName {
pctx.errors.add(errorf(node, "verb %q is not exported, did you mean to use %q instead?", node.Name.Name, expName))
return nil
}

Expand Down Expand Up @@ -1831,3 +1832,10 @@ func isIotaEnum(node ast.Node) bool {
return false
}
}

func exportedName(name string) string {
if name == "" {
return ""
}
return string(unicode.ToUpper(rune(name[0]))) + name[1:]
}
Loading