You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Asserts are no longer enabled by default for non-debug sessions #4379
There might already be a way to do this that I didn't find, but I would like to be able to run code with asserts enabled without having to be running under the debugger. The primary motivation for not using the debugger is that the code runs slower.
My guess is that this would need to be a preference setting, but I'm happy with any solution you think would be best.
Hmmm, on the surface this feels like a bug to me. I was under the impression we always ran with asserts enabled from the IDE by default (because I assumed at dev time that's what you'd want), however I can repro this doesn't work and it's because of this isDebug here:
if(isDebug&&debugConfig.enableAsserts!==false)// undefined = on
this.addArgsIfNotExist(args,"--enable-asserts");
It was added during the migration of flags from inside the debug adapter into the VS Code extension (to simplify the new debug adapters), but it doesn't appear to have had this condition when it was in the debug adapter. The change doesn't describe that it was deliberate, although it seems hard to do this accidentally.
I'm going to try removing that condition and running the bots and see what happens.
In the meantime, if you have a launch.json you can add --enable-asserts to toolArgs. This will apply to running using the Run/Debug menu (and pressing F5 etc.), but to make it apply to the Run/Debug CodeLens (the links above main/test/group methods), it needs to be marked as a template with templateFor: "":
{"version": "0.2.0","configurations": [{"name": "dart","request": "launch","type": "dart","toolArgs": ["--enable-asserts"// enable asserts],"templateFor": "",// use as the template for Run/Debug for the whole project (this is a path prefix, empty string matches the entire project)}]}
changed the title [-]A way to enable asserts when not running the debugger[/-][+]Asserts are no longer enabled by default for non-debug sessions[/+]on Feb 8, 2023
@bwilkerson btw I kicked off a pre-release version with this in it earlier. If you're on the pre-release Dart extension and have updated to v3.59.20230208 (note the last digit is an 8, there was a pre-release yesterday ending 7 but otherwise the same) and reloaded, then asserts should be on by default and not need the launch.json gymnastics above (unless you want to disable asserts).
I can't be certain this change in default behaviour won't upset anyone, but it was the original and intended behaviour. If this poses a problem we can add a setting to make it easier to control without needing a launch configuration.
Activity
DanTup commentedon Feb 8, 2023
Hmmm, on the surface this feels like a bug to me. I was under the impression we always ran with asserts enabled from the IDE by default (because I assumed at dev time that's what you'd want), however I can repro this doesn't work and it's because of this
isDebughere:Dart-Code/src/extension/providers/debug_config_provider.ts
Lines 635 to 636 in 7a2a7cc
It was added during the migration of flags from inside the debug adapter into the VS Code extension (to simplify the new debug adapters), but it doesn't appear to have had this condition when it was in the debug adapter. The change doesn't describe that it was deliberate, although it seems hard to do this accidentally.
I'm going to try removing that condition and running the bots and see what happens.
In the meantime, if you have a
launch.jsonyou can add--enable-assertstotoolArgs. This will apply to running using the Run/Debug menu (and pressingF5etc.), but to make it apply to the Run/Debug CodeLens (the links above main/test/group methods), it needs to be marked as a template withtemplateFor: "":Enable asserts by default for "without debugging" runs
DanTup commentedon Feb 8, 2023
This was originally implemented in af06b7f for #3702 but had no tests which would've probably have picked up the regression.
Bots are all green so I'm going to restore this (and add tests).
[-]A way to enable asserts when not running the debugger[/-][+]Asserts are no longer enabled by default for non-debug sessions[/+]Add tests for assertion default/flag
DanTup commentedon Feb 8, 2023
@bwilkerson btw I kicked off a pre-release version with this in it earlier. If you're on the pre-release Dart extension and have updated to v3.59.20230208 (note the last digit is an 8, there was a pre-release yesterday ending 7 but otherwise the same) and reloaded, then asserts should be on by default and not need the
launch.jsongymnastics above (unless you want to disable asserts).I can't be certain this change in default behaviour won't upset anyone, but it was the original and intended behaviour. If this poses a problem we can add a setting to make it easier to control without needing a launch configuration.
Enable asserts by default for "without debugging" runs