diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc index d837830bcea..23c45fdd92e 100644 --- a/runtime/vm/parser.cc +++ b/runtime/vm/parser.cc @@ -9091,7 +9091,7 @@ AstNode* Parser::ParseAssertStatement() { ConsumeToken(); // Consume assert keyword. ExpectToken(Token::kLPAREN); const intptr_t condition_pos = TokenPos(); - if (!I->flags().asserts() && !I->flags().type_checks()) { + if (!I->flags().asserts()) { SkipExpr(); ExpectToken(Token::kRPAREN); return NULL; diff --git a/tests/language/assertion_test.dart b/tests/language/assertion_test.dart index 68bdf04b1b7..2f0a12d4962 100644 --- a/tests/language/assertion_test.dart +++ b/tests/language/assertion_test.dart @@ -1,7 +1,7 @@ // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// VMOptions=--enable_type_checks +// VMOptions=--enable_asserts // // Dart test program testing assert statements. diff --git a/tests/standalone/no_assert_test.dart b/tests/standalone/no_assert_test.dart new file mode 100644 index 00000000000..825578b590d --- /dev/null +++ b/tests/standalone/no_assert_test.dart @@ -0,0 +1,16 @@ +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// VMOptions=--no-enable_asserts --enable_type_checks + +// Ensure that enabling of type checks does not automatically enable asserts. + +main() { + assert(false); + try { + int i = "String"; + throw "FAIL"; + } on TypeError catch (e) { + print("PASS"); + } +} diff --git a/tests/standalone/standalone.status b/tests/standalone/standalone.status index 03ca40dcbb4..4f1cd7031d7 100644 --- a/tests/standalone/standalone.status +++ b/tests/standalone/standalone.status @@ -17,6 +17,9 @@ issue14236_test: Pass # Do not remove this line. It serves as a marker for Issue javascript_compatibility_errors_test/none: Fail, OK # Not possible to exclude or annotate with '/// none:' +[ $runtime != vm ] +no_assert_test: Fail, OK # This is testing a vm flag. + [ $runtime == vm ] package/package_isolate_test: Fail # Issue 12474 io/observatory_test: Fail diff --git a/tools/testing/dart/compiler_configuration.dart b/tools/testing/dart/compiler_configuration.dart index fc1d536e0e0..9ec90f00271 100644 --- a/tools/testing/dart/compiler_configuration.dart +++ b/tools/testing/dart/compiler_configuration.dart @@ -155,7 +155,12 @@ class NoneCompilerConfiguration extends CompilerConfiguration { List sharedOptions, List originalArguments, CommandArtifact artifact) { - return [] + List args = []; + if (isChecked) { + args.add('--enable_asserts'); + args.add('--enable_type_checks'); + } + return args ..addAll(vmOptions) ..addAll(sharedOptions) ..addAll(originalArguments); @@ -315,6 +320,10 @@ class AnalyzerCompilerConfiguration extends CompilerConfiguration { CommandBuilder commandBuilder, List arguments, Map environmentOverrides) { + arguments = new List.from(arguments); + if (isChecked) { + arguments.add('--enable_type_checks'); + } return new CommandArtifact( [ commandBuilder.getAnalysisCommand( diff --git a/tools/testing/dart/test_suite.dart b/tools/testing/dart/test_suite.dart index aef5b3f2a06..b4e7b537396 100644 --- a/tools/testing/dart/test_suite.dart +++ b/tools/testing/dart/test_suite.dart @@ -2225,10 +2225,6 @@ class TestUtils { static List standardOptions(Map configuration) { List args = ["--ignore-unrecognized-flags"]; - if (configuration["checked"]) { - args.add('--enable_asserts'); - args.add("--enable_type_checks"); - } String compiler = configuration["compiler"]; if (compiler == "dart2js") { args = ['--generate-code-with-compile-time-errors', '--test-mode'];