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 non-constant format string errors with Go 1.24 #1745

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

michel-slm
Copy link

@michel-slm michel-slm commented Jan 26, 2025

Use errors.New instead of fmt.Errorf and fmt.Fprint instead of fmt.Fprintf if a non-constant string is used

golang/go#60529

Use `errors.New` instead of `fmt.Errorf` and `fmt.Fprint` instead of
`fmt.Fprintf` if a non-constant string is used

Signed-off-by: Michel Lind <[email protected]>
Comment on lines +82 to 85
return nil, errors.New(
"at CST BuildMultipleArityFunctionCallsiteNode: function name not found: " +
builtinFunctionInfo.name,
)
Copy link

@QuLogic QuLogic Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could make this (and others) actually format instead of a concatenation:

Suggested change
return nil, errors.New(
"at CST BuildMultipleArityFunctionCallsiteNode: function name not found: " +
builtinFunctionInfo.name,
)
return nil, fmt.Errorf(
"at CST BuildMultipleArityFunctionCallsiteNode: function name not found: %s",
builtinFunctionInfo.name,
)

@@ -163,7 +164,7 @@ func (root *RootNode) IngestAST(
err = nil

if ast.RootNode == nil {
return hadWarnings, fmt.Errorf("cannot build CST from nil AST root")
return hadWarnings, errors.New("cannot build CST from nil AST root")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one's actually fine.

Copy link
Owner

@johnkerl johnkerl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants