Branch: refs/heads/master
Revision: fe36965
Author: vasslitvinov
Log Message:
Merge pull request #17047 from vasslitvinov/if-var
Enable the “if-var” construct for conditionals
Implements Strategy (1b) in #13639.
Allows the following syntax:
if const X = someExpression() { // must be a class
.... // X is guaranteed to be non-nil
// X is a borrow, except it is unmanaged if someExpression() is
}
as well as the following variants:
-
var X
instead ofconst X
makes X modifiable within the then-block -
then
keyword instead of{}
and else-clauses are allowed as usual
Initially this PR contained applications of this construct in a couple of places in the modules.
I took them out for now and will add them back in later by reverting 391973eae0
r: @mppf
Modified Files:
A test/classes/nilability/if-var-1.chpl
A test/classes/nilability/if-var-1.good
A test/classes/nilability/if-var-2-const.chpl
A test/classes/nilability/if-var-2-const.good
A test/classes/nilability/if-var-2-int.chpl
A test/classes/nilability/if-var-2-int.good
A test/classes/nilability/if-var-2-scope.chpl
A test/classes/nilability/if-var-2-scope.good
A test/classes/nilability/if-var-2-type.chpl
A test/classes/nilability/if-var-2-type.good
M compiler/AST/build.cpp
M compiler/AST/primitive.cpp
M compiler/include/bison-chapel.h
M compiler/include/build.h
M compiler/include/flex-chapel.h
M compiler/include/primitive_list.h
M compiler/parser/bison-chapel.cpp
M compiler/parser/chapel.ypp
M compiler/parser/flex-chapel.cpp
M compiler/passes/normalize.cpp
M compiler/passes/scopeResolve.cpp
M modules/internal/ChapelBase.chpl
Compare: Comparing 10a2e58aa947...fe36965a376c · chapel-lang/chapel · GitHub