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

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion pkg/dsl/cst/builtin_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package cst

import (
"errors"
"fmt"

"github.com/johnkerl/miller/v6/pkg/bifs"
Expand Down Expand Up @@ -78,7 +79,7 @@ func (root *RootNode) BuildMultipleArityFunctionCallsiteNode(
return root.BuildTernaryFunctionCallsiteNode(astNode, builtinFunctionInfo)
}

return nil, fmt.Errorf(
return nil, errors.New(
"at CST BuildMultipleArityFunctionCallsiteNode: function name not found: " +
builtinFunctionInfo.name,
)
Comment on lines +82 to 85
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,
)

Expand Down
3 changes: 2 additions & 1 deletion pkg/dsl/cst/lvalues.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package cst

import (
"errors"
"fmt"
"os"

Expand Down Expand Up @@ -62,7 +63,7 @@ func (root *RootNode) BuildAssignableNode(
return root.BuildEnvironmentVariableLvalueNode(astNode)
}

return nil, fmt.Errorf(
return nil, errors.New(
"at CST BuildAssignableNode: unhandled AST node " + string(astNode.Type),
)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/dsl/cst/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package cst

import (
"container/list"
"errors"
"fmt"
"os"
"strings"
Expand Down Expand Up @@ -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.

}

// Check for things that are syntax errors but not done in the AST for
Expand Down Expand Up @@ -417,7 +418,7 @@ func (root *RootNode) resolveSubroutineCallsites() error {
return err
}
if uds == nil {
return fmt.Errorf("mlr: subroutine name not found: " + subroutineName)
return errors.New("mlr: subroutine name not found: " + subroutineName)
}

unresolvedSubroutineCallsite.uds = uds
Expand Down
Loading