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
Should a program using split-init such as the below be allowed?
proc test() {
var a;
if option then
a =new R(1);
elsereturn;
moreStatements(a);
}
PR #14814 implements this, but previous to that PR, this program would not compile, because the else branch of the conditional does not initialize a.
However it is not a problem for this program to compile as-is, because moreStatements(a) will always access an initialized a, and a will simply not be initialized (or deinitialized) if the else branch is taken.
This feature is motivated by an example using try inspired by Arkouda: #14748 (comment) but if we allow this rule for catch clauses it would make sense to also allow for conditionals. (Issue #14748 discusses whether split-init should be allowed within try statements at all, but try/catch is notionally related to if/else and so we would probably make the same choice for return/throw).
The text was updated successfully, but these errors were encountered:
Should a program using split-init such as the below be allowed?
PR #14814 implements this, but previous to that PR, this program would not compile, because the else branch of the conditional does not initialize
a
.However it is not a problem for this program to compile as-is, because
moreStatements(a)
will always access an initializeda
, anda
will simply not be initialized (or deinitialized) if the else branch is taken.This feature is motivated by an example using
try
inspired by Arkouda: #14748 (comment) but if we allow this rule forcatch
clauses it would make sense to also allow for conditionals. (Issue #14748 discusses whether split-init should be allowed withintry
statements at all, but try/catch is notionally related to if/else and so we would probably make the same choice for return/throw).The text was updated successfully, but these errors were encountered: