Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dart2js: --minify does not remove a string if the string is used in an interpolation / concatenation within a dead code block #13167

Closed
DartBot opened this issue Sep 8, 2013 · 6 comments
Labels
closed-not-planned Closed as we don't intend to take action on the reported issue P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js

Comments

@DartBot
Copy link

DartBot commented Sep 8, 2013

This issue was originally filed by ross.dart...@gmail.com


r27277
Windows 7x64

Consider the following program:

///////////////////////////////////////////////////////////////
import 'package:logging/logging.dart';

final _logger = new Logger('snarf');
const bool isLoggingEnabled = false;
int x = 42;

main() {
  log('please shake me out!');
}

log(String message) {
  if (isLoggingEnabled) {
    _logger.info('$x $message');
  }
}
///////////////////////////////////////////////////////////////

I would expect that 'please shake me out' would be removed by minification as the block wrapped by isLoggingEnabled is dead code. The interpolation with x inside of this (dead) block appears to keep it around. If I remove the interpolation with x it is removed from the output. I've tried also concatenation (+) and using a StringBuffer inside the same block, to no avail.

thanks,

@kasperl
Copy link

kasperl commented Sep 9, 2013

This sounds like a request for recognizing that certain parameters aren't used by the callee (because of dead code elimination) and avoiding to pass such parameters (as long as evaluating them do not have any side effects).


Removed Priority-Unassigned label.
Added Priority-Medium, Area-Dart2JS, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Sep 9, 2013

This comment was originally written by ross.dart...@gmail.com


Thanks, I had trouble finding the right words :)

Just to clarify:

A)

log(String message) {
  if (isLoggingEnabled) {
    _logger.info('$message');
  }
}

B)

log(String message) {
  if (isLoggingEnabled) {
    _logger.info('$x $message');
  }
}

C)

log(String message()) {
  if (isLoggingEnabled) {
    _logger.info('${message()}');
  }
}

(A) does get stripped from the output
(B) does not get stripped, but I'd expect that it could if (A) can (this issue report)
(C) was my first attempt, as using a closure to guard building the message is how I expected to shake the string, but in fact it seems to be enough to keep the string around so I've gone back to (A).

I'd like (B) to work so that I can have a central place to prefix some of my logging code, without having to put that logic at each call site. But basically I am just trying to find the best practices to allow for stripping my application's logging code at deployment time in a configurable manner.

thanks!

@kasperl
Copy link

kasperl commented Sep 18, 2013

Added this to the M7 milestone.

@kasperl
Copy link

kasperl commented Sep 23, 2013

Removed this from the M7 milestone.
Added this to the Later milestone.
Removed Priority-Medium label.
Added Priority-Low label.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@DartBot DartBot added Type-Defect P3 A lower priority bug or feature request web-dart2js labels Aug 4, 2014
@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed triaged labels Feb 29, 2016
@sigmundch sigmundch added the closed-not-planned Closed as we don't intend to take action on the reported issue label Jun 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-not-planned Closed as we don't intend to take action on the reported issue P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js
Projects
None yet
Development

No branches or pull requests

4 participants