Pub: Assert not present in debug mode for pub serve

Created on 6 Jun 2015  路  10Comments  路  Source: dart-lang/pub

_Originally opened as dart-lang/sdk#17657_

_This issue was originally filed by siri...@gmail.com_


What steps will reproduce the problem?

  1. Create a code that uses assert
  2. Use pub serve to serve it

What is the expected output? What do you see instead?

The asserts are not present at runtime, even forcing debug mode

What version of the product are you using? On what operating system?

Dev 33731

Please provide any additional information below.

as designed bug

All 10 comments

Comment by floitschG


_Added Area-Pub, Triaged labels._

Comment by nex3


Please provide more information. Is the code in question in a transformer, or in the application being served? Are you running your code on Dartium or on another browser via dart2js?

Comment by nex3


_Added NeedsInfo label._

_This comment was originally written by si...@gmail.com_


I'm talking about normal application code, served using pub serve, and in a browser using js. In fact, if I download the js file provided by pub serve there is no code that performs the assert, it's missing.

Thanks

Comment by nex3


Pub never enables checked mode in dart2js because it produces JavaScript that's prohibitively slow. You can enable it manually in your transformation configuration in your pubspec.yaml, though:

    transformers:
      $dart2js: {checked: true}


_Added AsDesigned label._

_This comment was originally written by sir...@gmail.com_


Thanks, that was really helpful. I was not aware of this behavior.

I'm surprised this issue is closed - it makes assert meaningless. If the only way turning it on is by massively slowing down the code nobody turns it on. I think there should be an extra flag only for enabling or disabling assert

The ability to turn on asserts and not turn on the rest of checked mode may be useful. Asserts are part of checked mode because checked mode checks and assert checks are so similar at the conceptual level, but if it is really helpful to have just one of them it shouldn't be much of a technical problem to implement it.

If dart2js were to add such a feature and enable it using a command line argument, say, --enable-assert, you would already be able to control it via pub's commandLineOptions, as shown here. A designated enableAssert: true option for pub could be convenient as well, but not essential. So it's really a dart2js issue, not a pub issue.

If you wish to push for an --enable-assert feature for dart2js, I think the natural next step would be to create a dart2js issue specifically on that.

Would be interesting how the behavior will be with DDC (checked mode, strong mode, performance, ...)
@jmesserly any thoughts?

asserts are always on in DDC. We may need a flag to compile without asserts at some point, but it does not exist right now, IIRC

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Timmmm picture Timmmm  路  4Comments

technolion picture technolion  路  5Comments

AbanoubWagih94 picture AbanoubWagih94  路  7Comments

micrcx picture micrcx  路  4Comments

AhmedAlaa96 picture AhmedAlaa96  路  6Comments