You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use JSON;
configconst useClass =true;
class C {
var x:int;
}
record R {
var x:int;
}
try {
if useClass {
// BUG: The error from the following can _not_ be caught:var x = fromJson("{\"y\": 10}", owned C);
writeln(x);
}
else {
// The error from the following can be caught after #26656:var x = fromJson("{\"y\": 10}", R);
writeln(x);
}
}
catch {
writeln("fromJson threw an error");
}
After #26656, we can catch errors when fromJson is used with a default-initializable type. But what #26656 does is just an attempt to paper over the issue. When you use non-default-initializable types, you still can not catch the error thrown by the internal implementation.
This issue has been there since those functions are created and has nothing to do with the way they are implemented, but more about the IO routines they use.
The text was updated successfully, but these errors were encountered:
Consider:
After #26656, we can catch errors when
fromJson
is used with a default-initializable type. But what #26656 does is just an attempt to paper over the issue. When you use non-default-initializable types, you still can not catch the error thrown by the internal implementation.This issue has been there since those functions are created and has nothing to do with the way they are implemented, but more about the IO routines they use.
The text was updated successfully, but these errors were encountered: