rascal icon indicating copy to clipboard operation
rascal copied to clipboard

Can not declare type for variables initialized by for expressions

Open codingfun2022 opened this issue 3 years ago • 0 comments

Describe the bug

for can be used as expressions, as verified by the following code:

L = for (int i <- [1..5]) append i * i;

but when I add type declaration for L, I got parse error.

list[int] L = for (int i <- [1..5]) append i * i;

To Reproduce

Steps to reproduce the behavior:

  1. Execute the following statement in REPL.
    list[int] L = for (int i <- [1..5]) append i * i;
    
  2. See parse error in REPL.

Expected behavior A list[int] variable named L should be defined without error instead of parse error.

Screenshots image

Stack traces None

Desktop (please complete the following information):

  • Context: Commandline REPL
  • Rascal Version [e.g. 0.23.0], stable release

Additional context None

codingfun2022 avatar Jul 15 '22 09:07 codingfun2022