Subject: | Using // breaks vertical alignment of = for two lines |
Given the code:
sub demo {
my $self = shift;
my $longname = shift // "xyz";
}
The tidied version SHOULD be:
sub demoA {
my $self = shift;
my $longname = shift // "xyz";
}
But the current version of perltidy doesn't add the extra spaces after $self to align the equal signs unless there's a third assignment. I'm attaching a file that shows the bug, the bug being worked around by putting the // in a separate statement, and the bug not manifesting when there are three consecutive assignments, after being run through perltidy -npro -b bug.pl. The file also has the output of perltidy -npro -b -dop so you can see what's enabled and what's not.
perl v5.24.0
Darwin kirby.home.packay.com 15.6.0 Darwin Kernel Version 15.6.0: Thu Sep 1 15:01:16 PDT 2016; root:xnu-3248.60.11~2/RELEASE_X86_64 x86_64
Subject: | bug.pl |
sub demoA {
my $self = shift;
my $longname = shift // "xyz";
}
sub demoB {
my $self = shift;
my $longname = shift;
$longname //= "xyz";
}
sub demoC {
my $self = shift;
my $longname = shift // "xyz";
my $evenlongername = shift;
}
__END__
$ perltidy -npro -b -dop
# Final parameter set for this run.
# See utility 'perltidyrc_dump.pl' for nicer formatting.
--add-newlines
--add-semicolons
--add-whitespace
--backup-and-modify-in-place
--backup-file-extension="bak"
--blank-lines-before-packages=1
--blank-lines-before-subs=1
--blanks-before-blocks
--blanks-before-comments
--block-brace-tightness=0
--block-brace-vertical-tightness=0
--nobrace-left-and-indent
--brace-tightness=1
--brace-vertical-tightness=0
--brace-vertical-tightness-closing=0
--break-at-old-attribute-breakpoints
--break-at-old-keyword-breakpoints
--break-at-old-logical-breakpoints
--break-at-old-ternary-breakpoints
--character-encoding="none"
--nocheck-syntax
--closing-brace-indentation=0
--closing-paren-indentation=0
--closing-side-comment-else-flag=0
--closing-side-comment-interval=6
--closing-side-comment-maximum-text=20
--closing-side-comments-balanced
--closing-square-bracket-indentation=0
--comma-arrow-breakpoints=5
--continuation-indentation=2
--nocuddled-else
--default-tabsize=8
--delete-old-newlines
--nodelete-old-whitespace
--delete-semicolons
--dump-options
--extended-syntax
--format="tidy"
--format-skipping
--fuzzy-line-length
--hanging-side-comments
--nohtml
--html-entities
--html-table-of-contents
--indent-block-comments
--indent-columns=4
--iterations=1
--keep-old-blank-lines=1
--nologfile
--long-block-line-count=8
--look-for-autoloader
--look-for-selfloader
--maximum-consecutive-blank-lines=1
--maximum-fields-per-table=0
--maximum-line-length=80
--memoize
--minimum-space-to-comment=4
--npro
--outdent-labels
--outdent-long-comments
--outdent-long-quotes
--paren-tightness=1
--paren-vertical-tightness=0
--paren-vertical-tightness-closing=0
--pass-version-line
--perl-syntax-check-flags="-c -T"
--pod2html
--noquiet
--recombine
--short-concatenation-item-length=8
--noshow-options
--space-for-semicolon
--square-bracket-tightness=1
--square-bracket-vertical-tightness=0
--square-bracket-vertical-tightness-closing=0
--static-block-comments
--nostatic-side-comments
--notabs
--trim-qw
--valign
--nowarning-output