New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not use argument-definition-tests in inner function. #8007
Comments
Double checking with Gilad if this is possible. In the meantime, you can check if onError is null, yes? cc @gbracha. |
This comment was originally written by @tomochikahara I already have worked around it by assignment to a temporary variable. Thanks a lot for your advice, and I hope the issue would be fix. |
It should work. This is an implementation bug, not a language issue. Recategorizing accordingly. Removed Area-Language label. |
Yes, that's a bug in the VM. It can see why it doesn't work, but I'm not sure what's the right way to fix it. The code in LocalScope::RestoreOuterScope builds a malformed scope chain, in the sense that there are variables that can be found by looping up the scope chain but it is impossible to find their owning scope by looping up the scope chain. The code in Parser::IsFormalParameter assumes that the scope chain is well-formed in the sense above. It seems reasonable to always have such well-formed scope chains, but the current code in LocalScope::RestoreOuterScope seems intentional so I'm not sure what will break if we change it. Regis? cc @crelier. |
A secondary issue is that variables apparently do not themselves know that they are parameters, except implicitly by appearing at a position k st. 0 <= k < argc in their owning scope. Scopes deserialized by LocalScope::RestoreOuterScope do not have this property. |
Thanks for the report, test case, and analysis. Added Accepted label. |
The issue here was that the parameter was from an outer scope and was also captured. Being captured, it was found by the lookup and therefore the code walking the scope chain was used. As Kevin indicated, the scope chain is not setup for the outer scope. Fixed at r17592. cc @kmillikin. |
This issue was originally filed by @tomochikahara
What steps will reproduce the problem?
List<Date> toDate(List<String> dateStrings, [onError(String)]) {
var df = new DateFormat("yyyyMMdd");
return dateStrings.map((str) {
try {
return df.parse(str);
} catch(e) {
if (?onError) {
onError(str);
} else {
throw e;
}
}
});
}
What is the expected output? What do you see instead?
I expected an argument-definition-test be evaluated correctly.
But, I got an error below.
file:///..()../sample.dart': Error: line 11 pos 12: formal parameter name expected
if (?onError) {
What version of the product are you using? On what operating system?
Dart Editor version 0.2.10_r16761
Dart SDK version 0.2.10.1_r16761
OS : Max OS X 10.8.2
Please provide any additional information below.
I guess that an argument-definition-test just refers to parameters of the most inner function.
This restriction doesn't exist in Dart's Language Specification.
The text was updated successfully, but these errors were encountered: