@tishlang/tish 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/tish +0 -0
- package/crates/tish/Cargo.toml +1 -1
- package/crates/tish_fmt/src/lib.rs +18 -0
- package/package.json +1 -1
- package/platform/darwin-arm64/tish +0 -0
- package/platform/darwin-x64/tish +0 -0
- package/platform/linux-arm64/tish +0 -0
- package/platform/linux-x64/tish +0 -0
- package/platform/win32-x64/tish.exe +0 -0
package/bin/tish
CHANGED
|
Binary file
|
package/crates/tish/Cargo.toml
CHANGED
|
@@ -1239,6 +1239,10 @@ impl Printer {
|
|
|
1239
1239
|
self.buf.push_str("typeof ");
|
|
1240
1240
|
self.child(operand, PREC_POSTFIX);
|
|
1241
1241
|
}
|
|
1242
|
+
Expr::Delete { target, .. } => {
|
|
1243
|
+
self.buf.push_str("delete ");
|
|
1244
|
+
self.child(target, PREC_POSTFIX);
|
|
1245
|
+
}
|
|
1242
1246
|
Expr::PostfixInc { name, .. } => {
|
|
1243
1247
|
self.buf.push_str(name.as_ref());
|
|
1244
1248
|
self.buf.push_str("++");
|
|
@@ -1519,6 +1523,7 @@ fn expr_prec(e: &Expr) -> u8 {
|
|
|
1519
1523
|
Expr::Binary { op, .. } => binop_prec(*op),
|
|
1520
1524
|
Expr::Unary { .. }
|
|
1521
1525
|
| Expr::TypeOf { .. }
|
|
1526
|
+
| Expr::Delete { .. }
|
|
1522
1527
|
| Expr::Await { .. }
|
|
1523
1528
|
| Expr::PrefixInc { .. }
|
|
1524
1529
|
| Expr::PrefixDec { .. } => 14,
|
|
@@ -2136,4 +2141,17 @@ let x = add(1, 2)
|
|
|
2136
2141
|
let out = format_source(src).unwrap();
|
|
2137
2142
|
assert_eq!(out, src, "{out:?}");
|
|
2138
2143
|
}
|
|
2144
|
+
|
|
2145
|
+
#[test]
|
|
2146
|
+
fn formats_delete_expression() {
|
|
2147
|
+
// Regression: Expr::Delete (the `delete` operator) must be handled by the formatter —
|
|
2148
|
+
// a non-exhaustive `match` here broke the `tish-format` build once the delete feature landed.
|
|
2149
|
+
let src = "fn f(o, k) {\ndelete o.a\ndelete o[\"b\"]\nlet x = delete o[k]\nreturn x\n}\n";
|
|
2150
|
+
let out = format_source(src).unwrap();
|
|
2151
|
+
assert!(out.contains("delete o.a"), "{out}");
|
|
2152
|
+
assert!(out.contains("delete o[\"b\"]"), "{out}");
|
|
2153
|
+
assert!(out.contains("delete o[k]"), "{out}");
|
|
2154
|
+
tishlang_parser::parse(&out).unwrap();
|
|
2155
|
+
assert_eq!(format_source(&out).unwrap(), out, "not idempotent:\n{out}");
|
|
2156
|
+
}
|
|
2139
2157
|
}
|
package/package.json
CHANGED
|
Binary file
|
package/platform/darwin-x64/tish
CHANGED
|
Binary file
|
|
Binary file
|
package/platform/linux-x64/tish
CHANGED
|
Binary file
|
|
Binary file
|