Skip to content

Commit 0447bd2

Browse files
authored
Run plugin with asserts when building test protos (#1055)
Currently we run the tests with assertions but that doesn't cover some of the code paths. When building the test protos we don't run the plugin with assertions. Add a new executable `protoc-gen-dart-debug` that is the same as `protoc-gen-dart`, but passes `--enable-asserts` to Dart. Use it when building test protos. This triggers an assertion which was reported in #608. The assertion is clearly wrong (we call the function for repeated fields a few lines above the assertion) and no one knows or remembers why it's there. Remove the assertion. Closes #608.
1 parent 660bbc8 commit 0447bd2

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

protoc_plugin/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ PLUGIN_SRC = \
33
lib/**/*.dart
44

55
OUTPUT_DIR=test/gen
6-
PLUGIN_NAME=protoc-gen-dart
6+
PLUGIN_NAME=protoc-gen-dart-debug
77
PLUGIN_PATH=bin/$(PLUGIN_NAME)
88

99
TEST_PROTO_LIST = \
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
BINDIR=$(dirname "$0")
3+
dart --enable-asserts "$BINDIR/protoc_plugin.dart" -c "$@"

protoc_plugin/lib/src/protobuf_field.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@ class ProtobufField {
393393

394394
/// Returns a function expression that returns the field's default value.
395395
String? generateDefaultFunction({bool omitIfFirstEnumValue = false}) {
396-
assert(!isRepeated);
397396
switch (descriptor.type) {
398397
case FieldDescriptorProto_Type.TYPE_BOOL:
399398
return _getDefaultAsBoolExpr(null);

0 commit comments

Comments
 (0)