Skip to content

Commit 1639297

Browse files
committed
fix(DynamicParser): Correctly handle throwing exceptions from method.
Fixes dart-archive#971
1 parent 260b511 commit 1639297

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

bin/parser_generator_for_spec.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ main(arguments) {
9696
'map["square"] = 6',
9797
'method',
9898
'method()',
99+
'causeException',
100+
'causeException()',
99101
'notAFn()',
100102
'notmixed',
101103
'obj[0].name=1',

lib/core/parser/parser_dynamic.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ class DynamicClosureMap implements ClosureMap {
4545
throw "Property '$name' is not of type function.";
4646
}
4747
} else {
48-
try {
49-
return reflect(o).invoke(symbol, posArgs, sNamedArgs).reflectee;
50-
} on NoSuchMethodError catch (e) {
51-
throw 'Undefined function $name';
52-
}
48+
return reflect(o).invoke(symbol, posArgs, sNamedArgs).reflectee;
5349
}
5450
};
5551
}

pubspec.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ packages:
6060
path:
6161
description: path
6262
source: hosted
63-
version: "1.1.0"
63+
version: "1.2.0"
6464
perf_api:
6565
description: perf_api
6666
source: hosted
@@ -76,7 +76,7 @@ packages:
7676
stack_trace:
7777
description: stack_trace
7878
source: hosted
79-
version: "0.9.3+1"
79+
version: "0.9.3+2"
8080
unittest:
8181
description: unittest
8282
source: hosted

test.js

Whitespace-only changes.

test/core/parser/parser_spec.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class TestData {
1010
set str(x) => _str = x;
1111

1212
method() => "testMethod";
13+
causeException() => this.x();
1314
sub1(a, {b: 0}) => a - b;
1415
sub2({a: 0, b: 0}) => a - b;
1516
}
@@ -435,6 +436,12 @@ main() {
435436
expect(context['obj'].field['key']).toEqual(4);
436437
});
437438

439+
iit('should rethrow an error from a function', () {
440+
expect(() {
441+
parser("causeException()").eval(new TestData());
442+
}).toThrow('NoSuchMethodError: method not found: \'x\'');
443+
});
444+
438445

439446
xit('should throw a nice error for type mismatch', () {
440447
context['obj'] = new SetterObject();

0 commit comments

Comments
 (0)