ernie-research/MEnvData-SWE huggingface dataset:
Repository: traefik/yaegi (Go)

Issue:
method resolution on aliased types
### The following program `sample.go` triggers an unexpected result

```go
package main

type Number int32

func (n Number) IsValid() bool { return true }

type Number1 = Number

type Number2 = Number1

func main() {
    a := Number2(5)
    println(a.IsValid())
}
```


### Expected result

```console
$ go run ./sample.go
true
```


### Got

```console
$ yaegi ./sample.go
run: ./sample.go:13:10: undefined selector: IsValid
```


### Yaegi Version

v0.12.0

### Additional Notes

Solving this issue would help making progress on #1133.


Discussion:

Patch:
diff --git a/interp/cfg.go b/interp/cfg.go
index 9feb76667..3da7c8017 100644
--- a/interp/cfg.go
+++ b/interp/cfg.go
@@ -2700,11 +2700,7 @@ func compositeGenerator(n *node, typ *itype, rtyp reflect.Type) (gen bltnGenerat
 		}
 	case valueT:
 		if rtyp == nil {
-			rtyp = n.typ.rtype
-		}
-		// TODO(mpl): I do not understand where this side-effect is coming from, and why it happens. quickfix for now.
-		if rtyp == nil {
-			rtyp = n.typ.val.rtype
+			rtyp = n.typ.TypeOf()
 		}
 		switch k := rtyp.Kind(); k {
 		case reflect.Struct:
diff --git a/interp/type.go b/interp/type.go
index 0bd3d406b..702d485bd 100644
--- a/interp/type.go
+++ b/interp/type.go
@@ -238,9 +238,6 @@ func namedOf(val *itype, path, name string, opts ...itypeOption) *itype {
 	if path != "" {
 		str = path + "." + name
 	}
-	for val.cat == aliasT {
-		val = val.val
-	}
 	t := &itype{cat: aliasT, val: val, path: path, name: name, str: str}
 	for _, opt := range opts {
 		opt(t)
@@ -1125,6 +1122,24 @@ func (t *itype) concrete() *itype {
 	return t
 }
 
+func (t *itype) underlying() *itype {
+	if t.cat == aliasT {
+		return t.val.underlying()
+	}
+	return t
+}
+
+// typeDefined returns true if type t1 is defined from type t2 or t2 from t1.
+func typeDefined(t1, t2 *itype) bool {
+	if t1.cat == aliasT && t1.val == t2 {
+		return true
+	}
+	if t2.cat == aliasT && t2.val == t1 {
+		return true
+	}
+	return false
+}
+
 // isVariadic returns true if the function type is variadic.
 // If the type is not a function or is not variadic, it will
 // return false.
@@ -1198,8 +1213,7 @@ func (t *itype) assignableTo(o *itype) bool {
 	if t.equals(o) {
 		return true
 	}
-	if t.cat == aliasT && o.cat == aliasT && t.val.id() != o.val.id() {
-		// If alias types are not identical, it is not assignable.
+	if t.cat == aliasT && o.cat == aliasT && (t.underlying().id() != o.underlying().id() || !typeDefined(t, o)) {
 		return false
 	}
 	if t.isNil() && o.hasNil() || o.isNil() && t.hasNil() {


Test patch:
diff --git a/_test/issue-1411.go b/_test/issue-1411.go
new file mode 100644
index 000000000..bf95f0b83
--- /dev/null
+++ b/_test/issue-1411.go
@@ -0,0 +1,16 @@
+package main
+
+type Number int32
+
+func (n Number) IsValid() bool { return true }
+
+type Number1 = Number
+
+type Number2 = Number1
+
+func main() {
+	a := Number2(5)
+	println(a.IsValid())
+}
+
+// Output: true
Repository: pingcap/tidb (Go)

Issue:
Get error data too long when use values for bit(1). 
## Bug Report

Please answer these questions before submitting your issue. Thanks!

1. What did you do?
<!--If possible, provide a recipe for reproducing the error.-->
```
create table t(id int primary key auto_increment, a bit(1));
insert into t values(1,1);
insert into t values(1,1) on duplicate key update id = values(id),a = values(a);
```

2. What did you expect to see?

No error.

3. What did you see instead?
```
tidb> create table t(id int primary key auto_increment, a bit(1));
Query OK, 0 rows affected (0.01 sec)

tidb> insert into t values(1,1);
Query OK, 1 row affected (0.00 sec)

tidb> insert into t values(1,1) on duplicate key update id = values(id),a = values(a);
ERROR 1406 (22001): Data Too Long, field len 1
```
4. What version of TiDB are you using (`tidb-server -V` or run `select tidb_version();` on TiDB)?
master  and release-3.0.10



Discussion:

Patch:
diff --git a/expression/builtin_other.go b/expression/builtin_other.go
index e67e6037c6abb..e90c5d31e6016 100644
--- a/expression/builtin_other.go
+++ b/expression/builtin_other.go
@@ -797,6 +797,19 @@ func (b *builtinValuesIntSig) evalInt(_ chunk.Row) (int64, bool, error) {
 		if row.IsNull(b.offset) {
 			return 0, true, nil
 		}
+		// For BinaryLiteral, see issue #15310
+		val := row.GetRaw(b.offset)
+		if len(val) > 8 {
+			return 0, true, errors.New("Session current insert values is too long")
+		}
+		if len(val) < 8 {
+			var binary types.BinaryLiteral = val
+			v, err := binary.ToInt(b.ctx.GetSessionVars().StmtCtx)
+			if err != nil {
+				return 0, true, errors.Trace(err)
+			}
+			return int64(v), false, nil
+		}
 		return row.GetInt64(b.offset), false, nil
 	}
 	return 0, true, errors.Errorf("Session current insert values len %d and column's offset %v don't match", row.Len(), b.offset)


Test patch:
diff --git a/expression/integration_test.go b/expression/integration_test.go
index fdbae91195798..3605c66154c94 100755
--- a/expression/integration_test.go
+++ b/expression/integration_test.go
@@ -5341,6 +5341,21 @@ func (s *testIntegrationSuite) TestCastStrToInt(c *C) {
 	}
 }
 
+func (s *testIntegrationSuite) TestValuesForBinaryLiteral(c *C) {
+	// See issue #15310
+	tk := testkit.NewTestKit(c, s.store)
+	tk.MustExec("use test;")
+	tk.MustExec("create table testValuesBinary(id int primary key auto_increment, a bit(1));")
+	tk.MustExec("insert into testValuesBinary values(1,1);")
+	err := tk.ExecToErr("insert into testValuesBinary values(1,1) on duplicate key update id = values(id),a = values(a);")
+	c.Assert(err, IsNil)
+	tk.MustQuery("select a=0 from testValuesBinary;").Check(testkit.Rows("0"))
+	err = tk.ExecToErr("insert into testValuesBinary values(1,0) on duplicate key update id = values(id),a = values(a);")
+	c.Assert(err, IsNil)
+	tk.MustQuery("select a=0 from testValuesBinary;").Check(testkit.Rows("1"))
+	tk.MustExec("drop table testValuesBinary;")
+}
+
 func (s *testIntegrationSuite) TestIssue14159(c *C) {
 	tk := testkit.NewTestKitWithInit(c, s.store)
 	tk.MustExec("DROP TABLE IF EXISTS t")
Repository: pingcap/tidb (Go)

Issue:
Rename a non-exists column should not success
## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

```sql
create table t (a int);
alter table t rename column c to c;
```

<!-- a step by step guide for reproducing the bug. -->

### 2. What did you expect to see? (Required)

```sql
mysql> alter table t rename column c to c;
ERROR 1054 (42S22): Unknown column 'c' in 't'
```

### 3. What did you see instead (Required)

```sql
mysql> alter table t rename column c to c;
Query OK, 0 rows affected (0.01 sec)
```

### 4. What is your TiDB version? (Required)

<!-- Paste the output of SELECT tidb_version() -->
381e870c5



Discussion:

Patch:
diff --git a/ddl/ddl_api.go b/ddl/ddl_api.go
index 62ca166d8615e..27e509439d652 100644
--- a/ddl/ddl_api.go
+++ b/ddl/ddl_api.go
@@ -4728,12 +4728,6 @@ func (d *ddl) ChangeColumn(ctx context.Context, sctx sessionctx.Context, ident a
 func (d *ddl) RenameColumn(ctx sessionctx.Context, ident ast.Ident, spec *ast.AlterTableSpec) error {
 	oldColName := spec.OldColumnName.Name
 	newColName := spec.NewColumnName.Name
-	if oldColName.L == newColName.L {
-		return nil
-	}
-	if newColName.L == model.ExtraHandleName.L {
-		return dbterror.ErrWrongColumnName.GenWithStackByArgs(newColName.L)
-	}
 
 	schema, tbl, err := d.getSchemaAndTableByIdent(ctx, ident)
 	if err != nil {
@@ -4745,6 +4739,13 @@ func (d *ddl) RenameColumn(ctx sessionctx.Context, ident ast.Ident, spec *ast.Al
 		return infoschema.ErrColumnNotExists.GenWithStackByArgs(oldColName, ident.Name)
 	}
 
+	if oldColName.L == newColName.L {
+		return nil
+	}
+	if newColName.L == model.ExtraHandleName.L {
+		return dbterror.ErrWrongColumnName.GenWithStackByArgs(newColName.L)
+	}
+
 	allCols := tbl.Cols()
 	colWithNewNameAlreadyExist := table.FindCol(allCols, newColName.L) != nil
 	if colWithNewNameAlreadyExist {


Test patch:
diff --git a/ddl/column_modify_test.go b/ddl/column_modify_test.go
index 5ac4fdf7ab759..7967a72e4e952 100644
--- a/ddl/column_modify_test.go
+++ b/ddl/column_modify_test.go
@@ -438,6 +438,11 @@ func TestRenameColumn(t *testing.T) {
 
 	tk.MustExec("drop view test_rename_column_view")
 	tk.MustExec("drop table test_rename_column")
+
+	// Test rename a non-exists column. See https://github.com/pingcap/tidb/issues/34811.
+	tk.MustExec("drop table if exists t;")
+	tk.MustExec("create table t (a int);")
+	tk.MustGetErrCode("alter table t rename column b to b;", errno.ErrBadField)
 }
 
 func TestVirtualColumnDDL(t *testing.T) {
Repository: vitessio/vitess (Go)

Issue:
Selecting too much data that overflows the gRPC packet limit still reports `ERTooManyUserConnections`
#6630 was supposed to address this, but the regex used to match and map the gRPC error message seems to have only handled the case where too much data was being inserted, **not** selected.

As a result, on current main, if you have a table with wide columns, I see:

```
mysql> select * from t1 limit 900;      
ERROR 1203 (42000): target: keyspace1.0.primary: vttablet: rpc error: code = ResourceExhausted desc = grpc: trying to send message larger than max (18015277 vs. 16777216)
mysql> 
```

Error 1203 is `ERTooManyUserConnections`;  we want Error 1153 (`ERNetPacketTooLarge`).


Discussion:

Patch:
diff --git a/go/mysql/sql_error.go b/go/mysql/sql_error.go
index 41a5af4a700..73a18d5ae35 100644
--- a/go/mysql/sql_error.go
+++ b/go/mysql/sql_error.go
@@ -214,7 +214,7 @@ func convertToMysqlError(err error) error {
 	return NewSQLError(mysqlCode.num, mysqlCode.state, err.Error())
 }
 
-var isGRPCOverflowRE = regexp.MustCompile(`.*grpc: received message larger than max \(\d+ vs. \d+\)`)
+var isGRPCOverflowRE = regexp.MustCompile(`.*?grpc: (received|trying to send) message larger than max \(\d+ vs. \d+\)`)
 
 func demuxResourceExhaustedErrors(msg string) int {
 	switch {


Test patch:
diff --git a/go/mysql/sql_error_test.go b/go/mysql/sql_error_test.go
index 7efb1669534..c6fe2f65251 100644
--- a/go/mysql/sql_error_test.go
+++ b/go/mysql/sql_error_test.go
@@ -36,6 +36,9 @@ func TestDumuxResourceExhaustedErrors(t *testing.T) {
 		{"grpc: received message larger than max (99282 vs. 1234): trailer", ERNetPacketTooLarge},
 		{"grpc: received message larger than max (1234 vs. 1234)", ERNetPacketTooLarge},
 		{"header: grpc: received message larger than max (1234 vs. 1234)", ERNetPacketTooLarge},
+		{"grpc: trying to send message larger than max (18015277 vs. 16777216)", ERNetPacketTooLarge},
+		{"grpc: trying to send message larger than max (18015277 vs. 16777216): trailer", ERNetPacketTooLarge},
+		{"header: grpc: trying to send message larger than max (18015277 vs. 16777216)", ERNetPacketTooLarge},
 		// This should be explicitly handled by returning ERNetPacketTooLarge from the execturo directly
 		// and therefore shouldn't need to be teased out of another error.
 		{"in-memory row count exceeded allowed limit of 13", ERTooManyUserConnections},
Repository: pingcap/tidb (Go)

Issue:
Incorrect implementation of the builtin function `round`
## Bug Report

Please answer these questions before submitting your issue. Thanks!

1. What did you do?
If possible, provide a recipe for reproducing the error.

As mentioned in pingcap/tikv#5833,
```sql
select round(1, -2012);
```

2. What did you expect to see?
```sql
mysql> select round(1, -2012);
+-----------------+
| round(1, -2012) |
+-----------------+
| 0               |
+-----------------+

```


3. What did you see instead?
```sql
TiDB> select round(1, -2012);
+----------------------+
| round(1, -2012)      | 
+----------------------+
| -9223372036854775808 | 
+----------------------+
```


4. What version of TiDB are you using (`tidb-server -V` or run `select tidb_version();` on TiDB)?
```
Release Version: v4.0.0-alpha-677-g18e42cfd2
Git Commit Hash: 18e42cfd233fa04850c24469c413237e38f02726
Git Branch: feature/wasm
UTC Build Time: 2019-11-28 08:41:07
GoVersion: go version go1.13.4 linux/amd64
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
```



Discussion:

Patch:
diff --git a/types/helper.go b/types/helper.go
index f03dc1390c6de..917afe756e492 100644
--- a/types/helper.go
+++ b/types/helper.go
@@ -43,7 +43,11 @@ func Round(f float64, dec int) float64 {
 	if math.IsInf(tmp, 0) {
 		return f
 	}
-	return RoundFloat(tmp) / shift
+	result := RoundFloat(tmp) / shift
+	if math.IsNaN(result) {
+		return 0
+	}
+	return result
 }
 
 // Truncate truncates the argument f to dec decimal places.


Test patch:
diff --git a/expression/builtin_math_test.go b/expression/builtin_math_test.go
index 9498d3232c552..47f606680bee4 100644
--- a/expression/builtin_math_test.go
+++ b/expression/builtin_math_test.go
@@ -426,6 +426,8 @@ func (s *testEvaluatorSuite) TestRound(c *C) {
 		{[]interface{}{newDec("1.58"), 1}, newDec("1.6")},
 		{[]interface{}{newDec("23.298"), -1}, newDec("20")},
 		{[]interface{}{nil, 2}, nil},
+		{[]interface{}{1, -2012}, 0},
+		{[]interface{}{1, -201299999999999}, 0},
 	}
 
 	Dtbl := tblToDtbl(tbl)
Repository: vitessio/vitess (Go)

Issue:
sqlparser.CanonicalString() capitalizes enum values
#10068 introduces custom formatting. I found that it exports `enum` definitions incorrectly:

assume the next query/statement:
```sql
create table a (e enum('red','green','blue','orange','yellow'))
```
I expect `sqlparser.CanonicalString()` to generate:
```sql
CREATE TABLE `a` (\n\t`e` enum('red','green','blue','orange','yellow')\n)
```
but instead it exports:
```sql
CREATE TABLE `a` (\n\t`e` enum('RED','GREEN','BLUE','ORANGE','YELLOW')\n)
```

`enum` or `set` values should not be capitalized.





Discussion:

Patch:
diff --git a/go/vt/sqlparser/ast_format.go b/go/vt/sqlparser/ast_format.go
index 5c226157c3c..e736d6161dd 100644
--- a/go/vt/sqlparser/ast_format.go
+++ b/go/vt/sqlparser/ast_format.go
@@ -563,7 +563,14 @@ func (ct *ColumnType) Format(buf *TrackedBuffer) {
 	}
 
 	if ct.EnumValues != nil {
-		buf.astPrintf(ct, "(%s)", strings.Join(ct.EnumValues, ", "))
+		buf.WriteString("(")
+		for i, enum := range ct.EnumValues {
+			if i > 0 {
+				buf.WriteString(", ")
+			}
+			buf.astPrintf(ct, "%#s", enum)
+		}
+		buf.WriteString(")")
 	}
 
 	if ct.Unsigned {
diff --git a/go/vt/sqlparser/ast_format_fast.go b/go/vt/sqlparser/ast_format_fast.go
index d2e1e122907..6dead1008c3 100644
--- a/go/vt/sqlparser/ast_format_fast.go
+++ b/go/vt/sqlparser/ast_format_fast.go
@@ -764,9 +764,14 @@ func (ct *ColumnType) formatFast(buf *TrackedBuffer) {
 	}
 
 	if ct.EnumValues != nil {
-		buf.WriteByte('(')
-		buf.WriteString(strings.Join(ct.EnumValues, ", "))
-		buf.WriteByte(')')
+		buf.WriteString("(")
+		for i, enum := range ct.EnumValues {
+			if i > 0 {
+				buf.WriteString(", ")
+			}
+			buf.WriteString(enum)
+		}
+		buf.WriteString(")")
 	}
 
 	if ct.Unsigned {


Test patch:
diff --git a/go/vt/sqlparser/tracked_buffer_test.go b/go/vt/sqlparser/tracked_buffer_test.go
index 53cbe49088c..191fd75237a 100644
--- a/go/vt/sqlparser/tracked_buffer_test.go
+++ b/go/vt/sqlparser/tracked_buffer_test.go
@@ -136,6 +136,14 @@ func TestCanonicalOutput(t *testing.T) {
 			"alter table t1 row_format=compressed, character set=utf8",
 			"ALTER TABLE `t1` ROW_FORMAT COMPRESSED, CHARSET utf8",
 		},
+		{
+			"create table a (e enum('red','green','blue','orange','yellow'))",
+			"CREATE TABLE `a` (\n\t`e` enum('red', 'green', 'blue', 'orange', 'yellow')\n)",
+		},
+		{
+			"create table a (e set('red','green','blue','orange','yellow'))",
+			"CREATE TABLE `a` (\n\t`e` set('red', 'green', 'blue', 'orange', 'yellow')\n)",
+		},
 	}
 
 	for _, tc := range testcases {
Repository: vitessio/vitess (Go)

Issue:
Bug Report: Parsing OK response from MariaDB can fail during import
### Overview of the Issue

While MariaDB support is deprecated (see https://github.com/vitessio/vitess/issues/9518), we still support importing data from MariaDB through an unmanaged tablet. 

Since #10871 we always enable session state tracking as a client capability, but it turns out that MariaDB can return a packet where the `SERVER_SESSION_STATE_CHANGED` bit is set, but subsequently no additional information is available in the packet. 

This then errors with the following error:

```
invalid OK packet session state change length: &{[254 0 0 34 64 0 0] 0}
```

### Reproduction Steps

Import data from a recent MariaDB instance

### Binary Version

```sh
15 and later
```


### Operating System and Environment details

```sh
n/a
```


### Log Fragments

```sh
-
```



Discussion:

Patch:
diff --git a/go/mysql/conn.go b/go/mysql/conn.go
index a65f9d117d3..c7492aec35c 100644
--- a/go/mysql/conn.go
+++ b/go/mysql/conn.go
@@ -1483,12 +1483,9 @@ func (c *Conn) parseOKPacket(in []byte) (*PacketOK, error) {
 		// session tracking
 		if statusFlags&ServerSessionStateChanged == ServerSessionStateChanged {
 			length, ok := data.readLenEncInt()
-			if !ok {
-				return fail("invalid OK packet session state change length: %v", data)
-			}
-			// In case we have a zero length string, there's no additional information so
-			// we can return the packet.
-			if length == 0 {
+			if !ok || length == 0 {
+				// In case we have no more data or a zero length string, there's no additional information so
+				// we can return the packet.
 				return packetOK, nil
 			}
 


Test patch:
diff --git a/go/mysql/conn_flaky_test.go b/go/mysql/conn_flaky_test.go
index ada543e7efa..0a3579e90f5 100644
--- a/go/mysql/conn_flaky_test.go
+++ b/go/mysql/conn_flaky_test.go
@@ -360,6 +360,11 @@ func TestOkPackets(t *testing.T) {
 		expectedErr: "invalid OK packet warnings: &{[0 0 0 2 0] 0}",
 	}, {
 		dataIn: `
+00000000  FE 00 00 22 40 00 00                              |.....|`,
+		dataOut: `00000000  00 00 00 22 40 00 00 00  04 03 02 00 00           |..."@........|`,
+		cc:      CapabilityClientProtocol41 | CapabilityClientTransactions | CapabilityClientSessionTrack | CapabilityClientDeprecateEOF,
+	}, {
+		dataIn: `
 00000000  00 00 00 02 40 00 00 00  2a 03 28 00 26 66 32 37  |....@...*.(.&f27|
 00000010  66 36 39 37 31 2d 30 33  65 37 2d 31 31 65 62 2d  |f6971-03e7-11eb-|
 00000020  38 35 63 35 2d 39 38 61  66 36 35 61 36 64 63 34  |85c5-98af65a6dc4|
Repository: GoogleContainerTools/skaffold (Go)

Issue:
Dockerfiles with quotes on base image tags fail to parse
<!--
  Issues without logs and details are more complicated to fix.
  Please help us by filling the template below!
-->

### Expected behavior
Dockerfile parses correctly and `skaffold build` builds container image

### Actual behavior
`skaffold build` fails with:
```
➜  getting-started git:(main) ✗ skaffold build 
Generating tags...
 - skaffold-example -> skaffold-example:v1.35.0-54-ga04528748-dirty
Checking cache...
 - skaffold-example: Error checking cache.
getting hash for artifact "skaffold-example": getting dependencies for "skaffold-example": parsing ONBUILD instructions: retrieving image "golang:\"1.15": parsing reference "golang:\"1.15": could not parse reference: golang:"1.15
```

### Information

- Skaffold version: v1.35.2 (or any)
- Contents of skaffold.yaml:

```yaml
<paste your skaffold.yaml here>
```

Dockerfile:
```
FROM golang:"1.15"
RUN ls
```

This is happening because in our parsing logic, we remove quotes around base images provided in the `FROM` clause, but we only removing leading/trailing. This results in `golang:"1.15"` being passed in as `golang:"1.15`, which fails.

https://github.com/GoogleContainerTools/skaffold/blob/a04528748d452b69dc6a5ecf9bc427d593589720/pkg/skaffold/docker/parse.go#L443-L451


Discussion:

Patch:
diff --git a/pkg/skaffold/docker/parse.go b/pkg/skaffold/docker/parse.go
index 65f5436e693..4fcb28d91a9 100644
--- a/pkg/skaffold/docker/parse.go
+++ b/pkg/skaffold/docker/parse.go
@@ -440,13 +440,14 @@ func fromInstruction(node *parser.Node) from {
 // unquote remove single quote/double quote pairs around a string value.
 // It looks like FROM "scratch" and FROM 'scratch' and FROM """scratch"""...
 // are valid forms of FROM scratch.
+// Quotes are also accepted on tags, e.g. golang:"1.15".
 func unquote(v string) string {
-	unquoted := strings.TrimFunc(v, func(r rune) bool { return r == '"' })
+	unquoted := strings.ReplaceAll(v, "\"", "")
 	if unquoted != v {
 		return unquoted
 	}
 
-	unquoted = strings.TrimFunc(v, func(r rune) bool { return r == '\'' })
+	unquoted = strings.ReplaceAll(v, "'", "")
 	return unquoted
 }
 


Test patch:
diff --git a/pkg/skaffold/docker/parse_test.go b/pkg/skaffold/docker/parse_test.go
index ea64b7db179..bb00d668327 100644
--- a/pkg/skaffold/docker/parse_test.go
+++ b/pkg/skaffold/docker/parse_test.go
@@ -36,6 +36,8 @@ func TestUnquote(t *testing.T) {
 	testutil.CheckDeepEqual(t, `scratch`, unquote(`'scratch'`))
 	testutil.CheckDeepEqual(t, `scratch`, unquote(`''scratch''`))
 	testutil.CheckDeepEqual(t, `'scratch'`, unquote(`"'scratch'"`))
+	testutil.CheckDeepEqual(t, `golang:1.15`, unquote(`golang:"1.15"`))
+	testutil.CheckDeepEqual(t, `golang:1.15`, unquote(`golang:'1.15'`))
 }
 
 func TestRemoveExtraBuildArgs(t *testing.T) {
Repository: apache/gravitino (Java)

Issue:
[Improvement] ExpressionUtil.parseSortOrder incorrectly reads the sort direction so “ASC” and “DESC” are not interpreted correctly
### What would you like to be improved?

ExpressionUtil.parseSortOrder incorrectly reads the sort direction so “ASC” and “DESC” are not interpreted correctly.

You can add this code to testSortOrderFiledToExpression to show this:
```
    sortOrderFiled = List.of("f1 ASC");
    sortOrders = ExpressionUtil.sortOrderFiledToExpression(sortOrderFiled);
    Assertions.assertEquals(1, sortOrders.length);
    Assertions.assertEquals(SortOrders.ascending(NamedReference.field("f1")), sortOrders[0]);
```

### How should we improve?

In parseSortOrder in trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/ExpressionUtil.java change the group from 1 to 2.


Discussion:
@justinmclean Hi, I’d like to take this issue.
All yours, if you need any help, just ask.



Patch:
diff --git a/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/ExpressionUtil.java b/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/ExpressionUtil.java
index 5642b81cb3f..6c5cafe3e7e 100644
--- a/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/ExpressionUtil.java
+++ b/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/ExpressionUtil.java
@@ -297,7 +297,7 @@ private static void parseSortOrder(List<SortOrder> sortOrders, String value) {
                 (m) -> {
                   NamedReference.FieldReference sortField = NamedReference.field(m.group(1));
                   SortDirection sortDirection =
-                      m.group(1).equalsIgnoreCase(SORT_DIRECTION_ASC)
+                      m.group(2).equalsIgnoreCase(SORT_DIRECTION_ASC)
                           ? SortDirection.ASCENDING
                           : SortDirection.DESCENDING;
                   NullOrdering nullOrdering =


Test patch:
diff --git a/trino-connector/trino-connector/src/test/java/org/apache/gravitino/trino/connector/catalog/iceberg/TestExpressionUtil.java b/trino-connector/trino-connector/src/test/java/org/apache/gravitino/trino/connector/catalog/iceberg/TestExpressionUtil.java
index 086429f213b..0b7f4975f7c 100644
--- a/trino-connector/trino-connector/src/test/java/org/apache/gravitino/trino/connector/catalog/iceberg/TestExpressionUtil.java
+++ b/trino-connector/trino-connector/src/test/java/org/apache/gravitino/trino/connector/catalog/iceberg/TestExpressionUtil.java
@@ -270,6 +270,11 @@ void testSortOrderFiledToExpression() {
         SortOrders.of(
             NamedReference.field("F4"), SortDirection.DESCENDING, NullOrdering.NULLS_FIRST),
         sortOrders[3]);
+
+    sortOrderFiled = List.of("f1 ASC");
+    sortOrders = ExpressionUtil.sortOrderFiledToExpression(sortOrderFiled);
+    Assertions.assertEquals(1, sortOrders.length);
+    Assertions.assertEquals(SortOrders.ascending(NamedReference.field("f1")), sortOrders[0]);
   }
 
   @Test
Repository: apache/gravitino (Java)

Issue:
[Improvement] Partition values set to null no longer trigger a NullPointerException in SparkPartitionUtils.java
### What would you like to be improved?

In toGravitinoLiteral  in spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/utils/SparkPartitionUtils.java

Here's a unit test to show that:
```
  @Test
  void testToGravitinoLiteralWithNull() {
    GenericInternalRow rowWithNull = new GenericInternalRow(new Object[] {null});
    Assertions.assertEquals(
        Literals.NULL,
        SparkPartitionUtils.toGravitinoLiteral(rowWithNull, 0, DataTypes.IntegerType));
  }
```

### How should we improve?

Convert nulls to Literals.NULL.


Discussion:
@justinmclean can I take this up ?

Sure



Patch:
diff --git a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/utils/SparkPartitionUtils.java b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/utils/SparkPartitionUtils.java
index a8e88b6b188..87898752004 100644
--- a/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/utils/SparkPartitionUtils.java
+++ b/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/utils/SparkPartitionUtils.java
@@ -46,6 +46,10 @@ public class SparkPartitionUtils {
   private SparkPartitionUtils() {}
 
   public static Literal<?> toGravitinoLiteral(InternalRow ident, int ordinal, DataType sparkType) {
+    if (ident.isNullAt(ordinal)) {
+      return Literals.NULL;
+    }
+
     if (sparkType instanceof ByteType) {
       return Literals.byteLiteral(ident.getByte(ordinal));
     } else if (sparkType instanceof ShortType) {


Test patch:
diff --git a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/utils/TestSparkPartitionUtils.java b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/utils/TestSparkPartitionUtils.java
index 1b9737b844a..b041ca945dc 100644
--- a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/utils/TestSparkPartitionUtils.java
+++ b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/utils/TestSparkPartitionUtils.java
@@ -150,4 +150,21 @@ void testGetSparkPartitionValue() {
             SparkPartitionUtils.getSparkPartitionValue(
                 "1970-01-01 00:00:00", DataTypes.TimestampType));
   }
+
+  @Test
+  void testToGravitinoLiteralWithMixedNullAndNonNull() {
+    GenericInternalRow mixedRow =
+        new GenericInternalRow(new Object[] {null, UTF8String.fromString("test"), 42});
+
+    Assertions.assertEquals(
+        Literals.NULL, SparkPartitionUtils.toGravitinoLiteral(mixedRow, 0, DataTypes.StringType));
+
+    Assertions.assertEquals(
+        Literals.stringLiteral("test"),
+        SparkPartitionUtils.toGravitinoLiteral(mixedRow, 1, DataTypes.StringType));
+
+    Assertions.assertEquals(
+        Literals.integerLiteral(42),
+        SparkPartitionUtils.toGravitinoLiteral(mixedRow, 2, DataTypes.IntegerType));
+  }
 }
Repository: apache/gravitino (Java)

Issue:
[Improvement] Improve ParseType.parseBasicType so it accepts whitespace around numeric parameters
### What would you like to be improved?

Improve ParseType.parseBasicType so it accepts whitespace around numeric parameters.

Here's two tests to illustrate what is needed:
```
  @Test
  public void testParseTypeDecimalWithSpaces() {
    Type type = ParseType.toType("decimal(10, 5)");
    assertThat(type, instanceOf(Types.DecimalType.class));
    assertEquals(10, ((Types.DecimalType) type).precision());
    assertEquals(5, ((Types.DecimalType) type).scale());
  }

  @Test
  public void testParseTypeVarcharWithSpaces() {
    Type type = ParseType.toType("varchar( 10 )");
    assertThat(type, instanceOf(Types.VarCharType.class));
    assertEquals(10, ((Types.VarCharType) type).length());
  }

```

### How should we improve?

as above


Discussion:
Hi @justinmclean, would you mind assign the task to me? I would like to fix it.
Sure, thanks for offering to help.



Patch:
diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/ParseType.java b/clients/cli/src/main/java/org/apache/gravitino/cli/ParseType.java
index afeb9246531..ee6bf3e0796 100644
--- a/clients/cli/src/main/java/org/apache/gravitino/cli/ParseType.java
+++ b/clients/cli/src/main/java/org/apache/gravitino/cli/ParseType.java
@@ -38,7 +38,7 @@ public class ParseType {
    * @throws IllegalArgumentException if the data type format is unsupported or malformed
    */
   public static ParsedType parseBasicType(String datatype) {
-    Pattern pattern = Pattern.compile("^(\\w+)\\((\\d+)(?:,(\\d+))?\\)$");
+    Pattern pattern = Pattern.compile("^(\\w+)\\(\\s*(\\d+)\\s*(?:,\\s*(\\d+)\\s*)?\\)$");
     Matcher matcher = pattern.matcher(datatype);
 
     if (matcher.matches()) {


Test patch:
diff --git a/clients/cli/src/test/java/org/apache/gravitino/cli/TestParseType.java b/clients/cli/src/test/java/org/apache/gravitino/cli/TestParseType.java
index 7587f85aef4..c4ceac0a251 100644
--- a/clients/cli/src/test/java/org/apache/gravitino/cli/TestParseType.java
+++ b/clients/cli/src/test/java/org/apache/gravitino/cli/TestParseType.java
@@ -140,4 +140,19 @@ public void testParseTypeMapWithNestedValue() {
     Type elementType = ((Types.ListType) valueType).elementType();
     assertThat(elementType, instanceOf(Types.IntegerType.class));
   }
+
+  @Test
+  public void testParseTypeDecimalWithSpaces() {
+    Type type = ParseType.toType("decimal(10, 5)");
+    assertThat(type, instanceOf(Types.DecimalType.class));
+    assertEquals(10, ((Types.DecimalType) type).precision());
+    assertEquals(5, ((Types.DecimalType) type).scale());
+  }
+
+  @Test
+  public void testParseTypeVarcharWithSpaces() {
+    Type type = ParseType.toType("varchar( 10 )");
+    assertThat(type, instanceOf(Types.VarCharType.class));
+    assertEquals(10, ((Types.VarCharType) type).length());
+  }
 }
Repository: apache/gravitino (Java)

Issue:
[Improvement] Double unlock should thow an exception in TreeLock.java
### What would you like to be improved?

In core/src/main/java/org/apache/gravitino/lock/TreeLock.java calling unlock with no loge should thow an exception.

Here a unit test to help:
```
  @Test
  void testDoubleUnlockThrows() {
    lock.lock(LockType.READ);
    lock.unlock();
    assertThrows(IllegalStateException.class, () -> lock.unlock());
  }
```

### How should we improve?

Fix and add tests.


Discussion:
@justinmclean 

Hi, can I take this issue?
All yours.



Patch:
diff --git a/core/src/main/java/org/apache/gravitino/lock/TreeLock.java b/core/src/main/java/org/apache/gravitino/lock/TreeLock.java
index 76f01e5d634..41f5300d486 100644
--- a/core/src/main/java/org/apache/gravitino/lock/TreeLock.java
+++ b/core/src/main/java/org/apache/gravitino/lock/TreeLock.java
@@ -143,6 +143,9 @@ public void unlock() {
     if (lockType == null) {
       throw new IllegalStateException("We must lock the tree lock before unlock it.");
     }
+    if (heldLocks.isEmpty()) {
+      throw new IllegalStateException("We must hold a lock before unlocking it.");
+    }
 
     while (!heldLocks.isEmpty()) {
       Pair<TreeLockNode, LockType> pair = heldLocks.pop();


Test patch:
diff --git a/core/src/test/java/org/apache/gravitino/lock/TestTreeLock.java b/core/src/test/java/org/apache/gravitino/lock/TestTreeLock.java
index b6a525da78b..2ff7c4e8e42 100644
--- a/core/src/test/java/org/apache/gravitino/lock/TestTreeLock.java
+++ b/core/src/test/java/org/apache/gravitino/lock/TestTreeLock.java
@@ -102,4 +102,11 @@ void testLockFailureAndUnlock() {
     Mockito.verify(mockNode2, Mockito.never()).unlock(Mockito.any());
     Mockito.verify(mockNode3, Mockito.never()).unlock(Mockito.any());
   }
+
+  @Test
+  void testDoubleUnlockThrows() {
+    lock.lock(LockType.READ);
+    lock.unlock();
+    assertThrows(IllegalStateException.class, () -> lock.unlock());
+  }
 }
Repository: apache/gravitino (Java)

Issue:
[Improvement] Handle empty paths in GCSTokenProvider.normalizeUriPath to avoid inserting extra trailing slash
### What would you like to be improved?

Currently the method normalizeUriPath in bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java doesn't handle empty paths correctly.

Here's a existing test modified to help:
```
 @Test
  void testNormalizePath() {
    Map<String, String> checkResults =
        ImmutableMap.of(
            "/a/b/", "a/b/",
            "/a/b", "a/b/",
            "a/b", "a/b/",
            "a/b/", "a/b/");
            "a/b/", "a/b/",
            "/", "",
            "", "");

    checkResults.forEach(
        (k, v) -> {
          String normalizedPath = GCSTokenProvider.normalizeUriPath(k);
          Assertions.assertEquals(v, normalizedPath);
        });
```


### How should we improve?

Fix handling of empty paths.


Discussion:
@justinmclean can I take this up ?
It's all yours



Patch:
diff --git a/bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java b/bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java
index 51720438ae3..f40f2ea49f5 100644
--- a/bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java
+++ b/bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java
@@ -146,6 +146,9 @@ static List<String> getAllResources(String resourcePath) {
   @VisibleForTesting
   // Remove the first '/', and append `/` if the path does not end with '/'.
   static String normalizeUriPath(String resourcePath) {
+    if (resourcePath.isEmpty() || "/".equals(resourcePath)) {
+      return "";
+    }
     if (resourcePath.startsWith("/")) {
       resourcePath = resourcePath.substring(1);
     }


Test patch:
diff --git a/bundles/gcp/src/test/java/org/apache/gravitino/gcs/credential/TestGCSTokenProvider.java b/bundles/gcp/src/test/java/org/apache/gravitino/gcs/credential/TestGCSTokenProvider.java
index 66326fc2ba1..9dfb7b64405 100644
--- a/bundles/gcp/src/test/java/org/apache/gravitino/gcs/credential/TestGCSTokenProvider.java
+++ b/bundles/gcp/src/test/java/org/apache/gravitino/gcs/credential/TestGCSTokenProvider.java
@@ -53,7 +53,9 @@ void testNormalizePath() {
             "/a/b/", "a/b/",
             "/a/b", "a/b/",
             "a/b", "a/b/",
-            "a/b/", "a/b/");
+            "a/b/", "a/b/",
+            "/", "",
+            "", "");
 
     checkResults.forEach(
         (k, v) -> {
Repository: mishoo/UglifyJS (JavaScript)

Issue:
ufuzz failure
```js
// original code
// (beautified)
var _calls_ = 10, a = 100, b = 10, c = 0;

export default function f0() {
    {
        var expr1 = a = "object";
        for (a in expr1) {
            if (a++ + ~b) {
                L90229: {}
            }
        }
    }
}

var a_1 = f0();

console.log(null, a, b, c, Infinity, NaN, undefined);
```
```js
// uglified code
// (beautified)
export default function() {}

b = 100, console.log(null, b, 10, 0, Infinity, NaN, void 0);
```
```
original result:
null 6 10 0 Infinity NaN undefined

uglified result:
null 100 10 0 Infinity NaN undefined
```
```js
// reduced test case (output will differ)

// (beautified)
var a;

export default function f0() {
    for (a in 0) {}
}

0(a);
// output: TypeError: 0 is not a function
// minify: ReferenceError: a is not defined
// options: {
//   "compress": {
//     "hoist_vars": true,
//     "keep_infinity": true,
//     "passes": 1000000,
//     "unsafe": true
//   },
//   "keep_fargs": true,
//   "keep_fnames": true,
//   "toplevel": true,
//   "output": {
//     "v8": true
//   },
//   "validate": true
// }
```
```
minify(options):
{
  "compress": {
    "hoist_vars": true,
    "keep_infinity": true,
    "passes": 1000000,
    "unsafe": true
  },
  "keep_fargs": true,
  "keep_fnames": true,
  "toplevel": true,
  "output": {
    "v8": true
  }
}

Suspicious compress options:
  evaluate
  hoist_vars
  reduce_vars
  sequences
  unused

Suspicious options:
  toplevel
```


Discussion:

Patch:
diff --git a/lib/compress.js b/lib/compress.js
index 515283f3e43..227616057fb 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -6905,7 +6905,7 @@ Compressor.prototype.compress = function(node) {
                     initializations.add(def.id, node);
                     if (tw.parent() instanceof AST_ExportDefault) {
                         export_defaults[def.id] = true;
-                        return;
+                        return scan_ref_scoped(node, descend, true);
                     }
                     if (drop && !(def.id in lambda_ids)) lambda_ids[def.id] = 1;
                     return true;


Test patch:
diff --git a/test/compress/exports.js b/test/compress/exports.js
index a5d0f1bdaaf..236a8af465b 100644
--- a/test/compress/exports.js
+++ b/test/compress/exports.js
@@ -560,3 +560,23 @@ issue_5444: {
         export var a = console;
     }
 }
+
+issue_5628: {
+    options = {
+        unused: true,
+    }
+    input: {
+        var a;
+        export default function f() {
+            for (a in 42);
+        }
+        console.log(a);
+    }
+    expect: {
+        var a;
+        export default function f() {
+            for (a in 42);
+        }
+        console.log(a);
+    }
+}
Repository: sindresorhus/eslint-plugin-unicorn (JavaScript)

Issue:
`prefer-array-flat-map`: false positive on React.Children.map()
`React.Children.map().flat()` gets flagged by `prefer-array-flat-map` even though `React.Children` has no `flatMap()`

From https://github.com/sindresorhus/eslint-plugin-unicorn/issues/347#issuecomment-610238873


Discussion:

Patch:
diff --git a/rules/prefer-array-flat-map.js b/rules/prefer-array-flat-map.js
index 05ec37424e..b043cdf2f6 100644
--- a/rules/prefer-array-flat-map.js
+++ b/rules/prefer-array-flat-map.js
@@ -2,6 +2,7 @@
 const getDocumentationUrl = require('./utils/get-documentation-url');
 const isMethodNamed = require('./utils/is-method-named');
 const isLiteralValue = require('./utils/is-literal-value');
+const {isNodeMatches} = require('./utils/is-node-matches');
 
 const MESSAGE_ID_FLATMAP = 'flat-map';
 const MESSAGE_ID_SPREAD = 'spread';
@@ -147,13 +148,15 @@ const create = context => ({
 			return;
 		}
 
-		const parent = node.callee.object;
-
-		if (!isMethodNamed(parent, 'map')) {
+		const calleeObject = node.callee.object;
+		if (
+			!isMethodNamed(calleeObject, 'map') ||
+			isNodeMatches(calleeObject.callee.object, ['React.Children', 'Children'])
+		) {
 			return;
 		}
 
-		reportFlatMap(context, node, parent);
+		reportFlatMap(context, node, calleeObject);
 	},
 	[SELECTOR_SPREAD]: node => {
 		context.report({


Test patch:
diff --git a/test/prefer-array-flat-map.mjs b/test/prefer-array-flat-map.mjs
index b958f1f8cf..d3c5956c8f 100644
--- a/test/prefer-array-flat-map.mjs
+++ b/test/prefer-array-flat-map.mjs
@@ -64,7 +64,11 @@ test({
 		'const foo = [].concat(...bar["map"]((i) => i));',
 		// Not `map`
 		'const foo = [].concat(...bar.notMap((i) => i));',
-		'const foo = [].concat(...[[4,5],6].flat());'
+		'const foo = [].concat(...[[4,5],6].flat());',
+
+		// Allowed
+		'Children.map(children, fn).flat()', // `import {Children} from 'react';`
+		'React.Children.map(children, fn).flat()'
 	],
 	invalid: [
 		{
Repository: kpdecker/jsdiff (JavaScript)

Issue:
diffWordsWithSpace - a char-by-char diff for spaces?
```js
require('diff').convertChangesToXML(
  require('diff').diffWordsWithSpace('foo\nbar', 'foo\n\n\nbar')
)
```

Returns:

```js
'foo<del>\n</del><ins>\n\n\n</ins>bar'
```

Desired output is:

```js
'foo<ins>\n\n</ins>bar'
```

As far as I understand, `diffWordsWithSpace` currently treats any amount of spaces as a single token. Which makes sense for `diffWords` (where space isn't significant), but doesn't work well for `diffWordsWithSpace`.

Suggestion: maybe it should compare spaces between words on character-by-character basis?

Possible solution - change regexp in [tokenizer](https://github.com/kpdecker/jsdiff/blob/8f8e0f296a6935a1854d1f2c0ea7ddac7e89a0ae/src/diff/word.js#L35) like this:

```diff
<   let tokens = value.split(/(\s+|\b)/);
---
>   let tokens = this.options.ignoreWhitespace ?
>                value.split(/(\s+|\b)/) :
>                value.split(/(\s|\b)/);
```

Seems to work fine for me, but I'm not quite sure it's correct.


Discussion:

Patch:
diff --git a/src/diff/word.js b/src/diff/word.js
index ab651ee9..6d8741de 100644
--- a/src/diff/word.js
+++ b/src/diff/word.js
@@ -32,7 +32,8 @@ wordDiff.equals = function(left, right) {
   return left === right || (this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right));
 };
 wordDiff.tokenize = function(value) {
-  let tokens = value.split(/(\s+|[()[\]{}'"]|\b)/);
+  // All whitespace symbols except newline group into one token, each newline - in separate token
+  let tokens = value.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/);
 
   // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
   for (let i = 0; i < tokens.length - 1; i++) {


Test patch:
diff --git a/test/diff/word.js b/test/diff/word.js
index 78338bc4..b1814d48 100644
--- a/test/diff/word.js
+++ b/test/diff/word.js
@@ -209,6 +209,15 @@ describe('WordDiff', function() {
       expect(convertChangesToXML(diffResult)).to.equal('&quot;<ins>word</ins>&quot;');
     });
 
+    it('should threat newline as separate token (issues #180, #211)', function() {
+      // #180
+      const diffResult1 = diffWordsWithSpace('foo\nbar', 'foo\n\n\nbar');
+      expect(convertChangesToXML(diffResult1)).to.equal('foo\n<ins>\n\n</ins>bar');
+      // #211
+      const diffResult2 = diffWordsWithSpace('A\n\nB\n', 'A\nB\n');
+      expect(convertChangesToXML(diffResult2)).to.equal('A\n<del>\n</del>B\n');
+    });
+
     it('should perform async operations', function(done) {
       diffWordsWithSpace('New Value  ', 'New  ValueMoreData ', function(err, diffResult) {
         expect(convertChangesToXML(diffResult)).to.equal('New<ins>  ValueMoreData</ins> <del>Value  </del>');
Repository: iamkun/dayjs (JavaScript)

Issue:
add(x, 'millisecond') method returns wrong value
## Example:
[runkit.com/roblav96/dayjs-bug](https://runkit.com/roblav96/dayjs-bug)

```js
dayjs(0).add(1000, 'millisecond').valueOf() // does not equal 1000000
```


Discussion:
Thanks, checking.
:tada: This issue has been resolved in version 1.5.24 :tada:

The release is available on:
- [npm package (@latest dist-tag)](https://www.npmjs.com/package/dayjs)
- [GitHub release](https://github.com/xx45/dayjs/releases/tag/v1.5.24)

Your **[semantic-release](https://github.com/semantic-release/semantic-release)** bot :package::rocket:



Patch:
diff --git a/package.json b/package.json
index 9243c8fda..d72ec3403 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "dayjs",
   "version": "0.0.0-development",
-  "description": "",
+  "description": "2KB immutable date library alternative to Moment.js with the same modern API ",
   "main": "dist/dayjs.min.js",
   "types": "index.d.ts",
   "scripts": {
@@ -23,6 +23,13 @@
       "src/*"
     ]
   },
+  "keywords": [
+    "dayjs",
+    "date",
+    "time",
+    "immutable",
+    "moment"
+  ],
   "author": "iamkun",
   "license": "MIT",
   "repository": {
diff --git a/src/index.js b/src/index.js
index 6e89b52db..853fd90d5 100644
--- a/src/index.js
+++ b/src/index.js
@@ -175,7 +175,8 @@ class Dayjs {
 
   add(number, units) {
     number = Number(number) // eslint-disable-line no-param-reassign
-    const unit = (units && units.length === 1) ? units : Utils.prettyUnit(units)
+    // units === 'ms' hard code here, will update in next release
+    const unit = (units && (units.length === 1 || units === 'ms')) ? units : Utils.prettyUnit(units)
     if (['M', C.M].indexOf(unit) > -1) {
       let date = this.set(C.DATE, 1).set(C.M, this.$M + number)
       date = date.set(C.DATE, Math.min(this.$D, date.daysInMonth()))
@@ -202,8 +203,12 @@ class Dayjs {
       case C.W:
         step = C.MILLISECONDS_A_WEEK
         break
-      default: // s seconds
+      case 's':
+      case C.S:
         step = C.MILLISECONDS_A_SECOND
+        break
+      default: // ms
+        step = 1
     }
     const nextTimeStamp = this.valueOf() + (number * step)
     return new Dayjs(nextTimeStamp)


Test patch:
diff --git a/test/manipulate.test.js b/test/manipulate.test.js
index 9c7aac810..76e87d278 100644
--- a/test/manipulate.test.js
+++ b/test/manipulate.test.js
@@ -28,6 +28,8 @@ describe('StartOf EndOf', () => {
 
 
 it('Add Time days', () => {
+  expect(dayjs().add(1, 'ms').valueOf()).toBe(moment().add(1, 'ms').valueOf())
+  expect(dayjs().add(1, 'milliseconds').valueOf()).toBe(moment().add(1, 'milliseconds').valueOf())
   expect(dayjs().add(1, 's').valueOf()).toBe(moment().add(1, 's').valueOf())
   expect(dayjs().add(1, 'seconds').valueOf()).toBe(moment().add(1, 'seconds').valueOf())
   expect(dayjs().add(1, 'm').valueOf()).toBe(moment().add(1, 'm').valueOf())
Repository: sindresorhus/eslint-plugin-unicorn (JavaScript)

Issue:
prevent-abbreviations: another meaning for the "dir" abbreviation
prevent-abbreviations automatically replaces `dir` with `directory`, but `dir` might mean `direction`. Example: `sortDir` - "sort direction".


Discussion:
We should probably add `direction` here: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/6b6cee586442997188904648cdb0b66022ad589d/rules/prevent-abbreviations.js#L119



Patch:
diff --git a/rules/prevent-abbreviations.js b/rules/prevent-abbreviations.js
index 8097cec3d6..123a6ff894 100644
--- a/rules/prevent-abbreviations.js
+++ b/rules/prevent-abbreviations.js
@@ -112,7 +112,8 @@ const defaultReplacements = {
 		library: true
 	},
 	dir: {
-		directory: true
+		directory: true,
+		direction: true
 	},
 	dirs: {
 		directories: true


Test patch:
diff --git a/test/prevent-abbreviations.js b/test/prevent-abbreviations.js
index 81a4645443..c1b621408f 100644
--- a/test/prevent-abbreviations.js
+++ b/test/prevent-abbreviations.js
@@ -224,7 +224,7 @@ ruleTester.run('prevent-abbreviations', rule, {
 		}),
 		noFixingTestCase({
 			code: 'this.eResDir = 1',
-			errors: createErrors('Please rename the property `eResDir`. Suggested names are: `errorResponseDirectory`, `errorResultDirectory`, `eventResponseDirectory`, ... (1 more omitted). A more descriptive name will do too.')
+			errors: createErrors('Please rename the property `eResDir`. Suggested names are: `errorResponseDirection`, `errorResponseDirectory`, `errorResultDirection`, ... (5 more omitted). A more descriptive name will do too.')
 		}),
 
 		{