nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: ManiacalLabs/BiblioPixel
Pull request #1146 (2019-11-25 17:20:06)

Use mido multi_receive instead of MultiPort to receive midi messages
I tested on Raspberry Pi & Windows and in both cases MultiPort would not yield midi messages, however multi_receive works perfectly.

p.s. I would open up an issue on mido but the dev seems to be inactive there.

VonHirsch: Failed due to FakeMido, should I also update that class and re-submit the PR?
adammhaile: @VonHirsch Just update the code and push to your branch. I recommend `git commit --amend --no-edit; git push -f origin MidiFix` so there's no new commit.
VonHirsch: ok thanks for that, done

Patch:
diff --git a/bibliopixel/control/midi.py b/bibliopixel/control/midi.py
index cfc6f5a..b98574d 100644
--- a/bibliopixel/control/midi.py
+++ b/bibliopixel/control/midi.py
@@ -77,7 +77,7 @@ class Midi(control.ExtractedLoop):
         port_names = ', '.join('"%s"' % p.name for p in ports)
         log.info('Starting to listen for MIDI on port%s %s',
                  '' if len(ports) == 1 else 's', port_names)
-        for port, msg in mido.ports.MultiPort(ports, yield_ports=True):
+        for port, msg in mido.ports.multi_receive(ports, yield_ports=True):
             mdict = dict(vars(msg), port=port)
 
             if self.use_note_off:


Test patch:
diff --git a/test/bibliopixel/control/midi_test.py b/test/bibliopixel/control/midi_test.py
index d21e4c8..45bad5c 100644
--- a/test/bibliopixel/control/midi_test.py
+++ b/test/bibliopixel/control/midi_test.py
@@ -22,7 +22,7 @@ class FakeMido:
                 return msgs
 
         self.ports = self
-        self.ports.MultiPort = multi_port
+        self.ports.multi_receive = multi_port
 
     def get_input_names(self):
         class Port(str):
Repository: ManiacalLabs/BiblioPixel
Pull request #1150 (2019-12-31 08:01:56)

Fix random sequence
My teammate had to make this change in order to get random sequences to work; I believe this may address #1149.


Patch:
diff --git a/bibliopixel/animation/sequence.py b/bibliopixel/animation/sequence.py
index 88e4d85..bf0879a 100644
--- a/bibliopixel/animation/sequence.py
+++ b/bibliopixel/animation/sequence.py
@@ -21,7 +21,7 @@ class Sequence(wrapper.Indexed):
             self.length = length and [length]
 
     def restart(self):
-        self.random and rand.shuffle(self.animations)
+        self.random and rand.shuffle(self.animations._animations)
         self.index = 0
 
     def pre_run(self):
diff --git a/bibliopixel/control/midi.py b/bibliopixel/control/midi.py
index cfc6f5a..b98574d 100644
--- a/bibliopixel/control/midi.py
+++ b/bibliopixel/control/midi.py
@@ -77,7 +77,7 @@ class Midi(control.ExtractedLoop):
         port_names = ', '.join('"%s"' % p.name for p in ports)
         log.info('Starting to listen for MIDI on port%s %s',
                  '' if len(ports) == 1 else 's', port_names)
-        for port, msg in mido.ports.MultiPort(ports, yield_ports=True):
+        for port, msg in mido.ports.multi_receive(ports, yield_ports=True):
             mdict = dict(vars(msg), port=port)
 
             if self.use_note_off:


Test patch:
diff --git a/test/bibliopixel/control/midi_test.py b/test/bibliopixel/control/midi_test.py
index d21e4c8..45bad5c 100644
--- a/test/bibliopixel/control/midi_test.py
+++ b/test/bibliopixel/control/midi_test.py
@@ -22,7 +22,7 @@ class FakeMido:
                 return msgs
 
         self.ports = self
-        self.ports.MultiPort = multi_port
+        self.ports.multi_receive = multi_port
 
     def get_input_names(self):
         class Port(str):
Repository: zeromicro/go-zero
Pull request #1220 (2021-11-10 03:48:17)

chore: redislock use stringx.randn replace randomStr func
redislock use stringx.randn replace randomStr func


Patch:
diff --git a/core/stores/redis/redislock.go b/core/stores/redis/redislock.go
index 06637a75..df962c06 100644
--- a/core/stores/redis/redislock.go
+++ b/core/stores/redis/redislock.go
@@ -1,6 +1,7 @@
 package redis
 
 import (
+	"github.com/tal-tech/go-zero/core/stringx"
 	"math/rand"
 	"strconv"
 	"sync/atomic"
@@ -45,7 +46,7 @@ func NewRedisLock(store *Redis, key string) *RedisLock {
 	return &RedisLock{
 		store: store,
 		key:   key,
-		id:    randomStr(randomLen),
+		id:    stringx.Randn(randomLen),
 	}
 }
 
@@ -92,11 +93,3 @@ func (rl *RedisLock) Release() (bool, error) {
 func (rl *RedisLock) SetExpire(seconds int) {
 	atomic.StoreUint32(&rl.seconds, uint32(seconds))
 }
-
-func randomStr(n int) string {
-	b := make([]byte, n)
-	for i := range b {
-		b[i] = letters[rand.Intn(len(letters))]
-	}
-	return string(b)
-}


Test patch:
diff --git a/core/stores/redis/redis_test.go b/core/stores/redis/redis_test.go
index 56cdb406..ae10b7d8 100644
--- a/core/stores/redis/redis_test.go
+++ b/core/stores/redis/redis_test.go
@@ -3,6 +3,7 @@ package redis
 import (
 	"crypto/tls"
 	"errors"
+	"github.com/tal-tech/go-zero/core/stringx"
 	"io"
 	"strconv"
 	"testing"
@@ -186,7 +187,7 @@ func TestRedis_Hscan(t *testing.T) {
 		key := "hash:test"
 		fieldsAndValues := make(map[string]string)
 		for i := 0; i < 1550; i++ {
-			fieldsAndValues["filed_"+strconv.Itoa(i)] = randomStr(i)
+			fieldsAndValues["filed_"+strconv.Itoa(i)] = stringx.Randn(i)
 		}
 		err := client.Hmset(key, fieldsAndValues)
 		assert.Nil(t, err)
@@ -550,7 +551,7 @@ func TestRedis_Sscan(t *testing.T) {
 		key := "list"
 		var list []string
 		for i := 0; i < 1550; i++ {
-			list = append(list, randomStr(i))
+			list = append(list, stringx.Randn(i))
 		}
 		lens, err := client.Sadd(key, list)
 		assert.Nil(t, err)
Repository: zeromicro/go-zero
Pull request #1224 (2021-11-10 13:31:21)

chore: remove unused const


Patch:
diff --git a/core/stores/redis/redislock.go b/core/stores/redis/redislock.go
index df962c06..7440d6dd 100644
--- a/core/stores/redis/redislock.go
+++ b/core/stores/redis/redislock.go
@@ -1,7 +1,6 @@
 package redis
 
 import (
-	"github.com/tal-tech/go-zero/core/stringx"
 	"math/rand"
 	"strconv"
 	"sync/atomic"
@@ -9,10 +8,10 @@ import (
 
 	red "github.com/go-redis/redis"
 	"github.com/tal-tech/go-zero/core/logx"
+	"github.com/tal-tech/go-zero/core/stringx"
 )
 
 const (
-	letters     = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
 	lockCommand = `if redis.call("GET", KEYS[1]) == ARGV[1] then
     redis.call("SET", KEYS[1], ARGV[1], "PX", ARGV[2])
     return "OK"


Test patch:
diff --git a/core/stores/redis/redis_test.go b/core/stores/redis/redis_test.go
index ae10b7d8..1e9251e1 100644
--- a/core/stores/redis/redis_test.go
+++ b/core/stores/redis/redis_test.go
@@ -3,7 +3,6 @@ package redis
 import (
 	"crypto/tls"
 	"errors"
-	"github.com/tal-tech/go-zero/core/stringx"
 	"io"
 	"strconv"
 	"testing"
@@ -12,6 +11,7 @@ import (
 	"github.com/alicebob/miniredis/v2"
 	red "github.com/go-redis/redis"
 	"github.com/stretchr/testify/assert"
+	"github.com/tal-tech/go-zero/core/stringx"
 )
 
 func TestRedis_Exists(t *testing.T) {
Repository: zeromicro/go-zero
Pull request #1235 (2021-11-13 13:32:47)

chore: remove conf.CheckedDuration


Patch:
diff --git a/core/conf/time.go b/core/conf/time.go
deleted file mode 100644
index be47300c..00000000
--- a/core/conf/time.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package conf
-
-import "time"
-
-const minDuration = 100 * time.Microsecond
-
-// CheckedDuration returns the duration that guaranteed to be greater than 100us.
-// Why we need this is because users sometimes intend to use 500 to represent 500ms.
-// In config, duration less than 100us should always be missing ms etc.
-func CheckedDuration(duration time.Duration) time.Duration {
-	if duration > minDuration {
-		return duration
-	}
-
-	return duration * time.Millisecond
-}


Test patch:
diff --git a/core/conf/time_test.go b/core/conf/time_test.go
deleted file mode 100644
index 130e0748..00000000
--- a/core/conf/time_test.go
+++ /dev/null
@@ -1,14 +0,0 @@
-package conf
-
-import (
-	"testing"
-	"time"
-
-	"github.com/stretchr/testify/assert"
-)
-
-func TestCheckedDuration(t *testing.T) {
-	assert.Equal(t, time.Second, CheckedDuration(1000))
-	assert.Equal(t, 2*time.Second, CheckedDuration(2000))
-	assert.Equal(t, 2*time.Second, CheckedDuration(time.Second*2))
-}
Repository: zeromicro/go-zero
Pull request #1276 (2021-11-26 05:47:04)

chore: only allow cors middleware to change headers
Adding this limitation because writing body and calling WriteHeader will cause confusing in middleware.


Patch:
diff --git a/rest/internal/cors/handlers.go b/rest/internal/cors/handlers.go
index 4547094a..c613b27d 100644
--- a/rest/internal/cors/handlers.go
+++ b/rest/internal/cors/handlers.go
@@ -45,12 +45,12 @@ func NotAllowedHandler(fn func(w http.ResponseWriter), origins ...string) http.H
 }
 
 // Middleware returns a middleware that adds CORS headers to the response.
-func Middleware(fn func(w http.ResponseWriter), origins ...string) func(http.HandlerFunc) http.HandlerFunc {
+func Middleware(fn func(w http.Header), origins ...string) func(http.HandlerFunc) http.HandlerFunc {
 	return func(next http.HandlerFunc) http.HandlerFunc {
 		return func(w http.ResponseWriter, r *http.Request) {
 			checkAndSetHeaders(w, r, origins)
 			if fn != nil {
-				fn(w)
+				fn(w.Header())
 			}
 
 			if r.Method == http.MethodOptions {
diff --git a/rest/server.go b/rest/server.go
index dd7d5b6b..23355ca9 100644
--- a/rest/server.go
+++ b/rest/server.go
@@ -106,10 +106,11 @@ func WithCors(origin ...string) RunOption {
 
 // WithCustomCors returns a func to enable CORS for given origin, or default to all origins (*),
 // fn lets caller customizing the response.
-func WithCustomCors(fn func(http.ResponseWriter), origin ...string) RunOption {
+func WithCustomCors(middlewareFn func(header http.Header), notAllowedFn func(http.ResponseWriter),
+	origin ...string) RunOption {
 	return func(server *Server) {
-		server.router.SetNotAllowedHandler(cors.NotAllowedHandler(fn, origin...))
-		server.Use(cors.Middleware(fn, origin...))
+		server.router.SetNotAllowedHandler(cors.NotAllowedHandler(notAllowedFn, origin...))
+		server.Use(cors.Middleware(middlewareFn, origin...))
 	}
 }
 


Test patch:
diff --git a/rest/internal/cors/handlers_test.go b/rest/internal/cors/handlers_test.go
index f5e8e017..047fdb98 100644
--- a/rest/internal/cors/handlers_test.go
+++ b/rest/internal/cors/handlers_test.go
@@ -114,8 +114,8 @@ func TestCorsHandlerWithOrigins(t *testing.T) {
 				r := httptest.NewRequest(method, "http://localhost", nil)
 				r.Header.Set(originHeader, test.reqOrigin)
 				w := httptest.NewRecorder()
-				handler := Middleware(func(w http.ResponseWriter) {
-					w.Header().Set("foo", "bar")
+				handler := Middleware(func(header http.Header) {
+					header.Set("foo", "bar")
 				}, test.origins...)(func(w http.ResponseWriter, r *http.Request) {
 					w.WriteHeader(http.StatusOK)
 				})
diff --git a/rest/server_test.go b/rest/server_test.go
index 1f36f916..ef814553 100644
--- a/rest/server_test.go
+++ b/rest/server_test.go
@@ -322,8 +322,10 @@ Port: 54321
 	srv, err := NewServer(cnf, WithRouter(rt))
 	assert.Nil(t, err)
 
-	opt := WithCustomCors(func(w http.ResponseWriter) {
-		w.Header().Set("foo", "bar")
+	opt := WithCustomCors(func(header http.Header) {
+		header.Set("foo", "bar")
+	}, func(w http.ResponseWriter) {
+		w.WriteHeader(http.StatusOK)
 	}, "local")
 	opt(srv)
 }
Repository: zeromicro/go-zero
Pull request #1278 (2021-11-26 07:32:36)

feat: support %w in logx.Errorf


Patch:
diff --git a/core/logx/logs.go b/core/logx/logs.go
index 81f23401..d3abc073 100644
--- a/core/logx/logs.go
+++ b/core/logx/logs.go
@@ -217,7 +217,7 @@ func ErrorCaller(callDepth int, v ...interface{}) {
 
 // ErrorCallerf writes v with context in format into error log.
 func ErrorCallerf(callDepth int, format string, v ...interface{}) {
-	errorTextSync(fmt.Sprintf(format, v...), callDepth+callerInnerDepth)
+	errorTextSync(fmt.Errorf(format, v...).Error(), callDepth+callerInnerDepth)
 }
 
 // Errorf writes v with format into error log.


Test patch:
diff --git a/core/logx/logs_test.go b/core/logx/logs_test.go
index cd3f37f5..03c77fcc 100644
--- a/core/logx/logs_test.go
+++ b/core/logx/logs_test.go
@@ -2,6 +2,7 @@ package logx
 
 import (
 	"encoding/json"
+	"errors"
 	"fmt"
 	"io"
 	"io/ioutil"
@@ -242,6 +243,16 @@ func TestSetLevelWithDuration(t *testing.T) {
 	assert.Equal(t, 0, writer.builder.Len())
 }
 
+func TestErrorfWithWrappedError(t *testing.T) {
+	SetLevel(ErrorLevel)
+	const message = "there"
+	writer := new(mockWriter)
+	errorLog = writer
+	atomic.StoreUint32(&initialized, 1)
+	Errorf("hello %w", errors.New(message))
+	assert.True(t, strings.Contains(writer.builder.String(), "hello there"))
+}
+
 func TestMustNil(t *testing.T) {
 	Must(nil)
 }
Repository: zeromicro/go-zero
Pull request #1280 (2021-11-27 09:39:45)

chore: cleanup zRPC retry code


Patch:
diff --git a/ROADMAP.md b/ROADMAP.md
index 51560a18..0f1f6fef 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -16,7 +16,6 @@ We hope that the items listed below will inspire further engagement from the com
 - [x] Support `username/password` authentication in ETCD
 - [x] Support `SSL/TLS` in `zRPC`
 - [x] Support `TLS` in redis connections
-- [ ] Support `retry strategies` in `zRPC`
 
 ## 2022
 - [ ] Support `goctl mock` command to start a mocking server with given `.api` file


Test patch:
diff --git a/zrpc/client_test.go b/zrpc/client_test.go
index d87c4806..16e005e4 100644
--- a/zrpc/client_test.go
+++ b/zrpc/client_test.go
@@ -96,19 +96,6 @@ func TestDepositServer_Deposit(t *testing.T) {
 			return invoker(ctx, method, req, reply, cc, opts...)
 		}),
 	)
-	retryClient := MustNewClient(
-		RpcClientConf{
-			Endpoints: []string{"foo"},
-			App:       "foo",
-			Token:     "bar",
-			Timeout:   1000,
-		},
-		WithDialOption(grpc.WithContextDialer(dialer())),
-		WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply interface{},
-			cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
-			return invoker(ctx, method, req, reply, cc, opts...)
-		}),
-	)
 	tarConfClient := MustNewClient(
 		RpcClientConf{
 			Target:  "foo",
@@ -133,7 +120,6 @@ func TestDepositServer_Deposit(t *testing.T) {
 	clients := []Client{
 		directClient,
 		nonBlockClient,
-		retryClient,
 		tarConfClient,
 		targetClient,
 	}
Repository: zeromicro/go-zero
Pull request #1367 (2021-12-25 11:35:02)

chore: add 1s for tolerance in redislock


Patch:
diff --git a/core/stores/redis/redislock.go b/core/stores/redis/redislock.go
index 3e85d972..69077850 100644
--- a/core/stores/redis/redislock.go
+++ b/core/stores/redis/redislock.go
@@ -16,9 +16,7 @@ const (
 else
     return 0
 end`
-	randomLen       = 16
-	tolerance       = 500 // milliseconds
-	millisPerSecond = 1000
+	randomLen = 16
 )
 
 // A RedisLock is a redis lock.
@@ -51,7 +49,7 @@ func (rl *RedisLock) Acquire() (bool, error) {
 	}
 
 	seconds := atomic.LoadUint32(&rl.seconds)
-	ok, err := rl.store.SetnxEx(rl.key, rl.id, int(seconds))
+	ok, err := rl.store.SetnxEx(rl.key, rl.id, int(seconds+1)) // +1s for tolerance
 	if err == red.Nil {
 		atomic.AddInt32(&rl.count, -1)
 		return false, nil
@@ -65,7 +63,6 @@ func (rl *RedisLock) Acquire() (bool, error) {
 	}
 
 	return true, nil
-
 }
 
 // Release releases the lock.


Test patch:
diff --git a/core/stores/redis/redislock_test.go b/core/stores/redis/redislock_test.go
index d12ed03e..2234f403 100644
--- a/core/stores/redis/redislock_test.go
+++ b/core/stores/redis/redislock_test.go
@@ -49,6 +49,5 @@ func TestRedisLock(t *testing.T) {
 		firstAcquire, err = firstLock.Acquire()
 		assert.Nil(t, err)
 		assert.True(t, firstAcquire)
-
 	})
 }
Repository: zeromicro/go-zero
Pull request #1404 (2022-01-02 06:36:23)

refactor: optimize fx


Patch:
diff --git a/core/fx/stream.go b/core/fx/stream.go
index c627e407..2f4056b1 100644
--- a/core/fx/stream.go
+++ b/core/fx/stream.go
@@ -90,7 +90,8 @@ func Range(source <-chan interface{}) Stream {
 func (s Stream) AllMach(predicate func(item interface{}) bool) bool {
 	for item := range s.source {
 		if !predicate(item) {
-			drain(s.source)
+			// make sure the former goroutine not block, and current func returns fast.
+			go drain(s.source)
 			return false
 		}
 	}
@@ -104,7 +105,8 @@ func (s Stream) AllMach(predicate func(item interface{}) bool) bool {
 func (s Stream) AnyMach(predicate func(item interface{}) bool) bool {
 	for item := range s.source {
 		if predicate(item) {
-			drain(s.source)
+			// make sure the former goroutine not block, and current func returns fast.
+			go drain(s.source)
 			return true
 		}
 	}
@@ -215,7 +217,7 @@ func (s Stream) First() interface{} {
 func (s Stream) ForAll(fn ForAllFunc) {
 	fn(s.source)
 	// avoid goroutine leak on fn not consuming all items.
-	drain(s.source)
+	go drain(s.source)
 }
 
 // ForEach seals the Stream with the ForEachFunc on each item, no successive operations.
@@ -310,7 +312,8 @@ func (s Stream) Merge() Stream {
 func (s Stream) NoneMatch(predicate func(item interface{}) bool) bool {
 	for item := range s.source {
 		if predicate(item) {
-			drain(s.source)
+			// make sure the former goroutine not block, and current func returns fast.
+			go drain(s.source)
 			return false
 		}
 	}


Test patch:
diff --git a/core/fx/stream_test.go b/core/fx/stream_test.go
index 92835993..3f5bbe5b 100644
--- a/core/fx/stream_test.go
+++ b/core/fx/stream_test.go
@@ -567,5 +567,5 @@ func runCheckedTest(t *testing.T, fn func(t *testing.T)) {
 	fn(t)
 	// let scheduler schedule first
 	time.Sleep(time.Millisecond)
-	assert.Equal(t, goroutines, runtime.NumGoroutine())
+	assert.True(t, runtime.NumGoroutine() <= goroutines)
 }
Repository: zeromicro/go-zero
Pull request #1441 (2022-01-12 09:45:25)

ci: add translator action


Patch:
diff --git a/.github/workflows/issue-translator.yml b/.github/workflows/issue-translator.yml
new file mode 100644
index 00000000..f8b0c1d6
--- /dev/null
+++ b/.github/workflows/issue-translator.yml
@@ -0,0 +1,18 @@
+name: 'issue-translator'
+on: 
+  issue_comment: 
+    types: [created]
+  issues: 
+    types: [opened]
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: tomsun28/issues-translate-action@v2.6
+        with:
+          IS_MODIFY_TITLE: true
+          # not require, default false, . Decide whether to modify the issue title
+          # if true, the robot account @Issues-translate-bot must have modification permissions, invite @Issues-translate-bot to your project or use your custom bot.
+          CUSTOM_BOT_NOTE: Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿
+          # not require. Customize the translation robot prefix message.


Test patch:
diff --git a/core/mr/mapreduce_test.go b/core/mr/mapreduce_test.go
index 252aed51..6ae2060d 100644
--- a/core/mr/mapreduce_test.go
+++ b/core/mr/mapreduce_test.go
@@ -266,6 +266,19 @@ func TestMapReduce(t *testing.T) {
 	}
 }
 
+func TestMapReducePanicBothMapperAndReducer(t *testing.T) {
+	defer goleak.VerifyNone(t)
+
+	_, _ = MapReduce(func(source chan<- interface{}) {
+		source <- 0
+		source <- 1
+	}, func(item interface{}, writer Writer, cancel func(error)) {
+		panic("foo")
+	}, func(pipe <-chan interface{}, writer Writer, cancel func(error)) {
+		panic("bar")
+	})
+}
+
 func TestMapReduceWithReduerWriteMoreThanOnce(t *testing.T) {
 	defer goleak.VerifyNone(t)
Repository: zeromicro/go-zero
Pull request #1452 (2022-01-16 02:24:29)

chore: remove jwt deprecated


Patch:
diff --git a/core/stores/redis/redis.go b/core/stores/redis/redis.go
index d6b197fe..2479fc49 100644
--- a/core/stores/redis/redis.go
+++ b/core/stores/redis/redis.go
@@ -880,6 +880,18 @@ func (s *Redis) Lrem(key string, count int, value string) (val int, err error) {
 	return
 }
 
+// Ltrim is the implementation of redis ltrim command.
+func (s *Redis) Ltrim(key string, start, stop int64) error {
+	return s.brk.DoWithAcceptable(func() error {
+		conn, err := getRedis(s)
+		if err != nil {
+			return err
+		}
+
+		return conn.LTrim(key, start, stop).Err()
+	}, acceptable)
+}
+
 // Mget is the implementation of redis mget command.
 func (s *Redis) Mget(keys ...string) (val []string, err error) {
 	err = s.brk.DoWithAcceptable(func() error {
diff --git a/rest/token/tokenparser.go b/rest/token/tokenparser.go
index a0cd9169..2e1ef68c 100644
--- a/rest/token/tokenparser.go
+++ b/rest/token/tokenparser.go
@@ -120,7 +120,5 @@ func WithResetDuration(duration time.Duration) ParseOption {
 }
 
 func newParser() *jwt.Parser {
-	return &jwt.Parser{
-		UseJSONNumber: true,
-	}
+	return jwt.NewParser(jwt.WithJSONNumber())
 }


Test patch:
diff --git a/core/stores/redis/redis_test.go b/core/stores/redis/redis_test.go
index eb85f419..92612654 100644
--- a/core/stores/redis/redis_test.go
+++ b/core/stores/redis/redis_test.go
@@ -361,6 +361,11 @@ func TestRedis_List(t *testing.T) {
 		vals, err = client.Lrange("key", 0, 10)
 		assert.Nil(t, err)
 		assert.EqualValues(t, []string{"value2", "value3", "value4"}, vals)
+		err = client.Ltrim("key", 0, 1)
+		assert.Nil(t, err)
+		vals, err = client.Lrange("key", 0, 10)
+		assert.Nil(t, err)
+		assert.EqualValues(t, []string{"value2", "value3"}, vals)
 	})
 }
Repository: elm-tooling/elm-language-server
Pull request #345 (2020-10-18 04:56:19)

Fix some definition bugs
Fix some bugs affecting inference in elm-markup. Added tests for each case. 


Patch:
diff --git a/src/util/treeUtils.ts b/src/util/treeUtils.ts
index f8c28c4..5dbeb10 100644
--- a/src/util/treeUtils.ts
+++ b/src/util/treeUtils.ts
@@ -502,8 +502,7 @@ export class TreeUtils {
             ret =
               pattern
                 .descendantsOfType("lower_pattern")
-                .find((a) => functionName === a.text)?.firstNamedChild ??
-              undefined;
+                .find((a) => functionName === a.text) ?? undefined;
             break;
           }
         }
@@ -689,7 +688,7 @@ export class TreeUtils {
       tree,
       nodeAtPosition.text,
     );
-    if (definitionNode) {
+    if (definitionNode && nodeAtPosition.parent?.type !== "union_pattern") {
       return { node: definitionNode, nodeType: "TypeAlias" };
     }
     if (


Test patch:
diff --git a/test/definitionProviderTests/typeResolveDefinition.test.ts b/test/definitionProviderTests/typeResolveDefinition.test.ts
index 3c5dae8..9fd455f 100644
--- a/test/definitionProviderTests/typeResolveDefinition.test.ts
+++ b/test/definitionProviderTests/typeResolveDefinition.test.ts
@@ -174,6 +174,26 @@ User { data = "" }
   type UnitlessFloat
   = UnitlessFloat
     --X   --^
+`;
+    await testBase.testDefinition(source);
+  });
+
+  it(`test union contructor should not resolve to type alias`, async () => {
+    const source = `
+type Page
+= Home
+  --X   
+
+type alias Home = {
+  field : String
+}
+
+func a = 
+  case a of
+    Home ->
+    --^ 
+      ""
+  
 `;
     await testBase.testDefinition(source);
   });
diff --git a/test/typeInference.test.ts b/test/typeInference.test.ts
index a74a11f..91291cc 100644
--- a/test/typeInference.test.ts
+++ b/test/typeInference.test.ts
@@ -520,4 +520,25 @@ func a b =
 `;
     await testTypeInference(basicsSources + source, "Int -> Float -> Model");
   });
+
+  test("let pattern defined after used in let expr", async () => {
+    const source = `
+--@ Test.elm
+module Test exposing (..)
+
+func a b =
+--^
+  let
+    var = c
+
+    { c, d } = a
+  in
+  var
+
+`;
+    await testTypeInference(
+      basicsSources + source,
+      "{ a | c : b, d : c } -> d -> e",
+    );
+  });
 });