nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: evcc-io/evcc
Pull request #18096 (2025-01-06 21:45:33)

chore: revert #17534 (c39990c)
Replace #https://github.com/evcc-io/evcc/pull/18064, https://github.com/evcc-io/evcc/pull/18066


Patch:
diff --git a/provider/const.go b/provider/const.go
index 692f15dc..d82b3b9c 100644
--- a/provider/const.go
+++ b/provider/const.go
@@ -11,7 +11,6 @@ import (
 )
 
 type constProvider struct {
-	*getter
 	ctx context.Context
 	str string
 	set Config
@@ -39,8 +38,6 @@ func NewConstFromConfig(ctx context.Context, other map[string]interface{}) (Prov
 		set: cc.Set,
 	}
 
-	p.getter = defaultGetters(p, 1)
-
 	return p, nil
 }
 
@@ -52,6 +49,45 @@ func (p *constProvider) StringGetter() (func() (string, error), error) {
 	}, nil
 }
 
+var _ IntProvider = (*constProvider)(nil)
+
+func (p *constProvider) IntGetter() (func() (int64, error), error) {
+	val, err := strconv.ParseInt(p.str, 10, 64)
+	if err != nil && p.str == "" {
+		err = nil
+	}
+
+	return func() (int64, error) {
+		return val, err
+	}, err
+}
+
+var _ FloatProvider = (*constProvider)(nil)
+
+func (p *constProvider) FloatGetter() (func() (float64, error), error) {
+	val, err := strconv.ParseFloat(p.str, 64)
+	if err != nil && p.str == "" {
+		err = nil
+	}
+
+	return func() (float64, error) {
+		return val, err
+	}, err
+}
+
+var _ BoolProvider = (*constProvider)(nil)
+
+func (p *constProvider) BoolGetter() (func() (bool, error), error) {
+	val, err := strconv.ParseBool(p.str)
+	if err != nil && p.str == "" {
+		err = nil
+	}
+
+	return func() (bool, error) {
+		return val, err
+	}, err
+}
+
 var _ SetIntProvider = (*constProvider)(nil)
 
 func (p *constProvider) IntSetter(param string) (func(int64) error, error) {


Test patch:
diff --git a/provider/const_test.go b/provider/const_test.go
new file mode 100644
index 00000000..aff1e4cf
--- /dev/null
+++ b/provider/const_test.go
@@ -0,0 +1,40 @@
+package provider
+
+import (
+	"context"
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+func TestConst(t *testing.T) {
+	p, err := NewConstFromConfig(context.TODO(), map[string]interface{}{"value": nil})
+	assert.NoError(t, err)
+
+	{
+		g, err := p.(StringProvider).StringGetter()
+		assert.NoError(t, err)
+
+		v, err := g()
+		assert.NoError(t, err)
+		assert.Equal(t, "", v)
+	}
+
+	{
+		g, err := p.(IntProvider).IntGetter()
+		assert.NoError(t, err)
+
+		v, err := g()
+		assert.NoError(t, err)
+		assert.Equal(t, int64(0), v)
+	}
+
+	{
+		g, err := p.(FloatProvider).FloatGetter()
+		assert.NoError(t, err)
+
+		v, err := g()
+		assert.NoError(t, err)
+		assert.Equal(t, float64(0), v)
+	}
+}