Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package StyLua for openSUSE:Factory checked in at 2022-12-24 14:52:00 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/StyLua (Old) and /work/SRC/openSUSE:Factory/.StyLua.new.1563 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "StyLua" Sat Dec 24 14:52:00 2022 rev:3 rq:1045044 version:0.15.3 Changes: -------- --- /work/SRC/openSUSE:Factory/StyLua/StyLua.changes 2022-12-01 17:22:37.962695726 +0100 +++ /work/SRC/openSUSE:Factory/.StyLua.new.1563/StyLua.changes 2022-12-24 14:53:02.703895395 +0100 @@ -1,0 +2,14 @@ +Fri Dec 16 16:00:34 UTC 2022 - Soc Virnyl Estela <socvirnyl.est...@gmail.com> + +- Disable --all-features in test since `cargo-insta` is + not installed or available in openSUSE. + +------------------------------------------------------------------- +Fri Dec 16 14:20:59 UTC 2022 - Soc Virnyl Estela <socvirnyl.est...@gmail.com> + +- Update to version 0.15.3: + * Fixed necessary parentheses removed in (-X) ^ Y causing change in semantics + * Take into account function token size when formatting an anonymous function function() end (particularly relevant when collapsing simple statements) + * Support hanging inside of Luau type arrays { T } to fix formatting issues when comments are present + +------------------------------------------------------------------- Old: ---- StyLua-0.15.2.tar.gz New: ---- StyLua-0.15.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ StyLua.spec ++++++ --- /var/tmp/diff_new_pack.gJiq4u/_old 2022-12-24 14:53:03.595900600 +0100 +++ /var/tmp/diff_new_pack.gJiq4u/_new 2022-12-24 14:53:03.599900623 +0100 @@ -18,7 +18,7 @@ %define _bin_name stylua Name: StyLua -Version: 0.15.2 +Version: 0.15.3 Release: 0 Summary: Opinionated Lua code formatter License: (Apache-2.0 OR MIT) AND Unicode-DFS-2016 AND (Apache-2.0 OR BSL-1.0) AND (Apache-2.0 OR MIT) AND (MIT OR Unlicense) AND Apache-2.0 AND MIT AND MPL-2.0 AND MPL-2.0 @@ -47,7 +47,7 @@ %{cargo_install} --all-features %check -%{cargo_test} --all-features +%{cargo_test} %files %{_bindir}/%{_bin_name} ++++++ StyLua-0.15.2.tar.gz -> StyLua-0.15.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/CHANGELOG.md new/StyLua-0.15.3/CHANGELOG.md --- old/StyLua-0.15.2/CHANGELOG.md 2022-10-31 10:55:48.000000000 +0100 +++ new/StyLua-0.15.3/CHANGELOG.md 2022-12-07 14:13:22.000000000 +0100 @@ -7,6 +7,14 @@ ## [Unreleased] +## [0.15.3] - 2022-12-07 + +### Fixed + +- Fixed necessary parentheses removed in `(-X) ^ Y` causing change in semantics ([#623](https://github.com/JohnnyMorganz/StyLua/issues/623)) +- Take into account `function` token size when formatting an anonymous function `function() end` (particularly relevant when collapsing simple statements) ([#619](https://github.com/JohnnyMorganz/StyLua/issues/619)) +- Support hanging inside of Luau type arrays `{ T }` to fix formatting issues when comments are present ([#617](https://github.com/JohnnyMorganz/StyLua/issues/617)) + ## [0.15.2] - 2022-10-31 ### Fixed @@ -584,7 +592,8 @@ Initial alpha release -[unreleased]: https://github.com/JohnnyMorganz/StyLua/compare/v0.15.2...HEAD +[unreleased]: https://github.com/JohnnyMorganz/StyLua/compare/v0.15.3...HEAD +[0.15.3]: https://github.com/JohnnyMorganz/StyLua/releases/tag/v0.15.3 [0.15.2]: https://github.com/JohnnyMorganz/StyLua/releases/tag/v0.15.2 [0.15.1]: https://github.com/JohnnyMorganz/StyLua/releases/tag/v0.15.1 [0.15.0]: https://github.com/JohnnyMorganz/StyLua/releases/tag/v0.15.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/Cargo.lock new/StyLua-0.15.3/Cargo.lock --- old/StyLua-0.15.2/Cargo.lock 2022-10-31 10:55:48.000000000 +0100 +++ new/StyLua-0.15.3/Cargo.lock 2022-12-07 14:13:22.000000000 +0100 @@ -917,7 +917,7 @@ [[package]] name = "stylua" -version = "0.15.2" +version = "0.15.3" dependencies = [ "anyhow", "assert_cmd", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/Cargo.toml new/StyLua-0.15.3/Cargo.toml --- old/StyLua-0.15.2/Cargo.toml 2022-10-31 10:55:48.000000000 +0100 +++ new/StyLua-0.15.3/Cargo.toml 2022-12-07 14:13:22.000000000 +0100 @@ -1,6 +1,6 @@ [package] name = "stylua" -version = "0.15.2" +version = "0.15.3" authors = ["JohnnyMorganz <johnnymorg...@outlook.com>"] description = "A code formatter for Lua" license = "MPL-2.0" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/README.md new/StyLua-0.15.3/README.md --- old/StyLua-0.15.2/README.md 2022-10-31 10:55:48.000000000 +0100 +++ new/StyLua-0.15.3/README.md 2022-12-07 14:13:22.000000000 +0100 @@ -54,7 +54,7 @@ ```yaml - repo: https://github.com/JohnnyMorganz/StyLua - rev: v0.15.2 + rev: v0.15.3 hooks: - id: stylua # or stylua-system / stylua-github ``` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/src/cli/main.rs new/StyLua-0.15.3/src/cli/main.rs --- old/StyLua-0.15.2/src/cli/main.rs 2022-10-31 10:55:48.000000000 +0100 +++ new/StyLua-0.15.3/src/cli/main.rs 2022-12-07 14:13:22.000000000 +0100 @@ -398,7 +398,7 @@ ) .context("failed to parse ignore file")?; - matches!(ignore.matched(&filepath, false), ignore::Match::Ignore(_)) + matches!(ignore.matched(filepath, false), ignore::Match::Ignore(_)) } None => false, }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/src/formatters/expression.rs new/StyLua-0.15.3/src/formatters/expression.rs --- old/StyLua-0.15.2/src/formatters/expression.rs 2022-10-31 10:55:48.000000000 +0100 +++ new/StyLua-0.15.3/src/formatters/expression.rs 2022-12-07 14:13:22.000000000 +0100 @@ -67,6 +67,12 @@ /// We should keep parentheses in this case to highlight precedence BinaryLHS, + /// The internal expression is on the LHS of a binary expression involving ^ + /// e.g. `(-X) ^ Y` + /// We need to keep parentheses here because ^ has higher precedence and is right associative + /// and removing parentheses changes meaning + BinaryLHSExponent, + /// The internal expression is having a unary operation applied to it: the `expr` part of #expr. /// If this occurs, and `expr` is a type assertion, then we need to keep the parentheses UnaryOrBinary, @@ -124,7 +130,9 @@ } => { // If the expression is of the format `(not X) and Y` or `(not X) == Y` etc. // Where internal_expression = not X, we should keep the parentheses - if let ExpressionContext::BinaryLHS = context { + if let ExpressionContext::BinaryLHSExponent = context { + return false; + } else if let ExpressionContext::BinaryLHS = context { if let UnOp::Not(_) = unop { return false; } @@ -146,7 +154,9 @@ if type_assertion.is_some() && matches!( context, - ExpressionContext::UnaryOrBinary | ExpressionContext::BinaryLHS + ExpressionContext::UnaryOrBinary + | ExpressionContext::BinaryLHS + | ExpressionContext::BinaryLHSExponent ) { return false; @@ -314,7 +324,12 @@ } } Expression::BinaryOperator { lhs, binop, rhs } => { - let lhs = format_expression_internal(ctx, lhs, ExpressionContext::BinaryLHS, shape); + let context = if let BinOp::Caret(_) = binop { + ExpressionContext::BinaryLHSExponent + } else { + ExpressionContext::BinaryLHS + }; + let lhs = format_expression_internal(ctx, lhs, context, shape); let binop = format_binop(ctx, binop, shape); let shape = shape.take_last_line(&lhs) + binop.to_string().len(); Expression::BinaryOperator { @@ -1141,12 +1156,12 @@ if contains_comments(&*lhs) { hang_binop_expression(ctx, *lhs, binop.clone(), shape, lhs_range) } else { - format_expression_internal( - ctx, - &lhs, - ExpressionContext::BinaryLHS, - lhs_shape, - ) + let context = if let BinOp::Caret(_) = binop { + ExpressionContext::BinaryLHSExponent + } else { + ExpressionContext::BinaryLHS + }; + format_expression_internal(ctx, &lhs, context, lhs_shape) }, hang_binop_expression( ctx, @@ -1168,7 +1183,12 @@ let lhs = if contains_comments(&*lhs) { hang_binop_expression(ctx, *lhs, binop.to_owned(), shape, lhs_range) } else { - format_expression_internal(ctx, &lhs, ExpressionContext::BinaryLHS, shape) + let context = if let BinOp::Caret(_) = binop { + ExpressionContext::BinaryLHSExponent + } else { + ExpressionContext::BinaryLHS + }; + format_expression_internal(ctx, &lhs, context, shape) }; let rhs = if contains_comments(&*rhs) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/src/formatters/functions.rs new/StyLua-0.15.3/src/formatters/functions.rs --- old/StyLua-0.15.2/src/formatters/functions.rs 2022-10-31 10:55:48.000000000 +0100 +++ new/StyLua-0.15.3/src/formatters/functions.rs 2022-12-07 14:13:22.000000000 +0100 @@ -39,8 +39,10 @@ function_body: &FunctionBody, shape: Shape, ) -> (TokenReference, FunctionBody) { + const FUNCTION_LEN: usize = "function".len(); + let function_token = fmt_symbol!(ctx, function_token, "function", shape); - let function_body = format_function_body(ctx, function_body, shape); + let function_body = format_function_body(ctx, function_body, shape.add_width(FUNCTION_LEN)); (function_token, function_body) } @@ -901,6 +903,7 @@ } #[cfg(not(feature = "luau"))] + #[allow(clippy::let_unit_value)] let return_type = (); break ( parameters_parentheses diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/src/formatters/luau.rs new/StyLua-0.15.3/src/formatters/luau.rs --- old/StyLua-0.15.2/src/formatters/luau.rs 2022-10-31 10:55:48.000000000 +0100 +++ new/StyLua-0.15.3/src/formatters/luau.rs 2022-12-07 14:13:22.000000000 +0100 @@ -14,7 +14,7 @@ UpdateLeadingTrivia, UpdateTrailingTrivia, UpdateTrivia, }, trivia_util::{ - contains_comments, contains_singleline_comments, + contains_comments, contains_singleline_comments, spans_multiple_lines, take_generic_parameter_trailing_comments, take_type_argument_trailing_comments, take_type_info_trailing_comments, token_contains_comments, token_trivia_contains_comments, trivia_contains_comments, trivia_is_comment, @@ -165,14 +165,56 @@ pub fn format_type_info(ctx: &Context, type_info: &TypeInfo, shape: Shape) -> TypeInfo { match type_info { TypeInfo::Array { braces, type_info } => { + const BRACKET_LEN: usize = "{ ".len(); + let (start_brace, end_brace) = braces.tokens().to_owned(); - let braces = ContainedSpan::new( - fmt_symbol!(ctx, start_brace, "{ ", shape), - fmt_symbol!(ctx, end_brace, " }", shape), - ); - let type_info = Box::new(format_type_info(ctx, type_info, shape + 2)); // 2 = "{ " - TypeInfo::Array { braces, type_info } + let contains_comments = start_brace.trailing_trivia().any(trivia_is_comment) + || end_brace.leading_trivia().any(trivia_is_comment) + || contains_comments(type_info); + + let (table_type, new_type_info) = if contains_comments { + (TableType::MultiLine, None) + } else { + let new_type_info = + format_hangable_type_info(ctx, type_info, shape + BRACKET_LEN, 0); + + ( + if spans_multiple_lines(&new_type_info) { + TableType::MultiLine + } else { + TableType::SingleLine + }, + Some(new_type_info), + ) + }; + let braces = create_table_braces(ctx, start_brace, end_brace, table_type, shape); + + let (new_type_info, leading_trivia, trailing_trivia) = match table_type { + TableType::MultiLine => ( + format_hangable_type_info( + ctx, + type_info, + shape.increment_additional_indent(), + 0, + ), + FormatTriviaType::Append(vec![create_indent_trivia( + ctx, + shape.increment_additional_indent(), + )]), + FormatTriviaType::Append(vec![create_newline_trivia(ctx)]), + ), + _ => ( + new_type_info.unwrap_or_else(|| format_type_info(ctx, type_info, shape)), + FormatTriviaType::NoChange, + FormatTriviaType::NoChange, + ), + }; + + TypeInfo::Array { + braces, + type_info: Box::new(new_type_info.update_trivia(leading_trivia, trailing_trivia)), + } } TypeInfo::Basic(token_reference) => { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/src/lib.rs new/StyLua-0.15.3/src/lib.rs --- old/StyLua-0.15.2/src/lib.rs 2022-10-31 10:55:48.000000000 +0100 +++ new/StyLua-0.15.3/src/lib.rs 2022-12-07 14:13:22.000000000 +0100 @@ -317,6 +317,7 @@ } /// Formats given [`Ast`] +#[allow(clippy::result_large_err)] pub fn format_ast( input_ast: Ast, config: Config, @@ -353,6 +354,7 @@ } /// Formats given Lua code +#[allow(clippy::result_large_err)] pub fn format_code( code: &str, config: Config, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/stylua-npm-bin/package-lock.json new/StyLua-0.15.3/stylua-npm-bin/package-lock.json --- old/StyLua-0.15.2/stylua-npm-bin/package-lock.json 2022-10-31 10:55:48.000000000 +0100 +++ new/StyLua-0.15.3/stylua-npm-bin/package-lock.json 2022-12-07 14:13:22.000000000 +0100 @@ -1,12 +1,12 @@ { "name": "@johnnymorganz/stylua-bin", - "version": "0.15.2", + "version": "0.15.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@johnnymorganz/stylua-bin", - "version": "0.15.2", + "version": "0.15.3", "hasInstallScript": true, "license": "MPL-2.0", "dependencies": { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/stylua-npm-bin/package.json new/StyLua-0.15.3/stylua-npm-bin/package.json --- old/StyLua-0.15.2/stylua-npm-bin/package.json 2022-10-31 10:55:48.000000000 +0100 +++ new/StyLua-0.15.3/stylua-npm-bin/package.json 2022-12-07 14:13:22.000000000 +0100 @@ -1,6 +1,6 @@ { "name": "@johnnymorganz/stylua-bin", - "version": "0.15.2", + "version": "0.15.3", "description": "A code formatter for Lua", "bin": { "stylua": "./run.js" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/tests/inputs/excess-parentheses-dont-remove.lua new/StyLua-0.15.3/tests/inputs/excess-parentheses-dont-remove.lua --- old/StyLua-0.15.2/tests/inputs/excess-parentheses-dont-remove.lua 2022-10-31 10:55:48.000000000 +0100 +++ new/StyLua-0.15.3/tests/inputs/excess-parentheses-dont-remove.lua 2022-12-07 14:13:22.000000000 +0100 @@ -2,3 +2,7 @@ -- Indicate precedence local _ = (not true) == true local _ = (not true) and false + +-- https://github.com/JohnnyMorganz/StyLua/issues/623 +-- Changes meaning +local y = (-X) ^ Y diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/tests/inputs-collapse-single-statement/over-column-width-3.lua new/StyLua-0.15.3/tests/inputs-collapse-single-statement/over-column-width-3.lua --- old/StyLua-0.15.2/tests/inputs-collapse-single-statement/over-column-width-3.lua 1970-01-01 01:00:00.000000000 +0100 +++ new/StyLua-0.15.3/tests/inputs-collapse-single-statement/over-column-width-3.lua 2022-12-07 14:13:22.000000000 +0100 @@ -0,0 +1,4 @@ +-- https://github.com/JohnnyMorganz/StyLua/issues/619 +local a = { + aa = function() return "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" end, +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/tests/inputs-luau/type-comments-3.lua new/StyLua-0.15.3/tests/inputs-luau/type-comments-3.lua --- old/StyLua-0.15.2/tests/inputs-luau/type-comments-3.lua 1970-01-01 01:00:00.000000000 +0100 +++ new/StyLua-0.15.3/tests/inputs-luau/type-comments-3.lua 2022-12-07 14:13:22.000000000 +0100 @@ -0,0 +1,8 @@ +-- https://github.com/JohnnyMorganz/StyLua/issues/617 +type Table = { + { + Key -- [1]: Key + | Translations -- [2]: Translations + | Tags -- [3]: Tags + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/tests/snapshots/tests__collapse_single_statem...@over-column-width-3.lua.snap new/StyLua-0.15.3/tests/snapshots/tests__collapse_single_statem...@over-column-width-3.lua.snap --- old/StyLua-0.15.2/tests/snapshots/tests__collapse_single_statem...@over-column-width-3.lua.snap 1970-01-01 01:00:00.000000000 +0100 +++ new/StyLua-0.15.3/tests/snapshots/tests__collapse_single_statem...@over-column-width-3.lua.snap 2022-12-07 14:13:22.000000000 +0100 @@ -0,0 +1,11 @@ +--- +source: tests/tests.rs +expression: "format_code(&contents,\n Config::default().with_collapse_simple_statement(CollapseSimpleStatement::Always),\n None, OutputVerification::None).unwrap()" +--- +-- https://github.com/JohnnyMorganz/StyLua/issues/619 +local a = { + aa = function() + return "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + end, +} + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/tests/snapshots/tests__l...@type-comments-3.lua.snap new/StyLua-0.15.3/tests/snapshots/tests__l...@type-comments-3.lua.snap --- old/StyLua-0.15.2/tests/snapshots/tests__l...@type-comments-3.lua.snap 1970-01-01 01:00:00.000000000 +0100 +++ new/StyLua-0.15.3/tests/snapshots/tests__l...@type-comments-3.lua.snap 2022-12-07 14:13:22.000000000 +0100 @@ -0,0 +1,13 @@ +--- +source: tests/tests.rs +expression: format(&contents) +--- +-- https://github.com/JohnnyMorganz/StyLua/issues/617 +type Table = { + { + Key -- [1]: Key + | Translations -- [2]: Translations + | Tags -- [3]: Tags + } +} + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/tests/snapshots/tests__stand...@excess-parentheses-dont-remove.lua.snap new/StyLua-0.15.3/tests/snapshots/tests__stand...@excess-parentheses-dont-remove.lua.snap --- old/StyLua-0.15.2/tests/snapshots/tests__stand...@excess-parentheses-dont-remove.lua.snap 2022-10-31 10:55:48.000000000 +0100 +++ new/StyLua-0.15.3/tests/snapshots/tests__stand...@excess-parentheses-dont-remove.lua.snap 2022-12-07 14:13:22.000000000 +0100 @@ -7,3 +7,7 @@ local _ = (not true) == true local _ = (not true) and false +-- https://github.com/JohnnyMorganz/StyLua/issues/623 +-- Changes meaning +local y = (-X) ^ Y + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/StyLua-0.15.2/wasm/package.json new/StyLua-0.15.3/wasm/package.json --- old/StyLua-0.15.2/wasm/package.json 2022-10-31 10:55:48.000000000 +0100 +++ new/StyLua-0.15.3/wasm/package.json 2022-12-07 14:13:22.000000000 +0100 @@ -4,7 +4,7 @@ "JohnnyMorganz <johnnymorg...@outlook.com>" ], "description": "A code formatter for Lua", - "version": "0.15.2", + "version": "0.15.3", "license": "MPL-2.0", "readme": "README.md", "repository": { ++++++ _service ++++++ --- /var/tmp/diff_new_pack.gJiq4u/_old 2022-12-24 14:53:03.795901766 +0100 +++ /var/tmp/diff_new_pack.gJiq4u/_new 2022-12-24 14:53:03.799901790 +0100 @@ -1,7 +1,7 @@ <services> <service name="download_files" mode="disabled" /> <service name="cargo_vendor" mode="disabled"> - <param name="srctar">StyLua-0.15.2.tar.gz</param> + <param name="srctar">StyLua-0.15.3.tar.gz</param> <param name="compression">gz</param> <param name="update">true</param> </service> ++++++ cargo_config ++++++ --- /var/tmp/diff_new_pack.gJiq4u/_old 2022-12-24 14:53:03.819901907 +0100 +++ /var/tmp/diff_new_pack.gJiq4u/_new 2022-12-24 14:53:03.823901929 +0100 @@ -3,4 +3,5 @@ [source.vendored-sources] directory = "vendor" +(No newline at EOF) ++++++ vendor.tar.gz ++++++ /work/SRC/openSUSE:Factory/StyLua/vendor.tar.gz /work/SRC/openSUSE:Factory/.StyLua.new.1563/vendor.tar.gz differ: char 5, line 1