Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

fix(DynamicParser): Correctly handle throwing exceptions from method. #1064

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bin/parser_generator_for_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ main(arguments) {
'map["square"] = 6',
'method',
'method()',
'causeException',
'causeException()',
'notAFn()',
'notmixed',
'obj[0].name=1',
Expand Down
6 changes: 1 addition & 5 deletions lib/core/parser/parser_dynamic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ class DynamicClosureMap implements ClosureMap {
throw "Property '$name' is not of type function.";
}
} else {
try {
return reflect(o).invoke(symbol, posArgs, sNamedArgs).reflectee;
} on NoSuchMethodError catch (e) {
throw 'Undefined function $name';
}
return reflect(o).invoke(symbol, posArgs, sNamedArgs).reflectee;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you verify that if you misspell a field name in an expression, the field name is still printed?

}
};
}
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ packages:
path:
description: path
source: hosted
version: "1.1.0"
version: "1.2.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this file from the PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the rationale for that ? (just to know, I have already committed updated lock files)

perf_api:
description: perf_api
source: hosted
Expand All @@ -76,7 +76,7 @@ packages:
stack_trace:
description: stack_trace
source: hosted
version: "0.9.3+1"
version: "0.9.3+2"
unittest:
description: unittest
source: hosted
Expand Down
Empty file added test.js
Empty file.
7 changes: 7 additions & 0 deletions test/core/parser/parser_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class TestData {
set str(x) => _str = x;

method() => "testMethod";
causeException() => this.x();
sub1(a, {b: 0}) => a - b;
sub2({a: 0, b: 0}) => a - b;
}
Expand Down Expand Up @@ -435,6 +436,12 @@ main() {
expect(context['obj'].field['key']).toEqual(4);
});

iit('should rethrow an error from a function', () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm iit

expect(() {
parser("causeException()").eval(new TestData());
}).toThrow('NoSuchMethodError');
});


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