ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.58k stars 737 forks source link

`check` keyword doesn't work in combination with `from` #31681

Open manuranga opened 3 years ago

manuranga commented 3 years ago
check from var entry in check file:readDir(SOURCE_DIR)
          do {

          };

above gives invalid usage of the 'check' expression operator: no matching error return type(s) in the enclosing invokable

MaryamZi commented 2 years ago

This error is logged when the checked error is not handled. e.g, the enclosing function/worker doesn't have error in the return type.

The following works.

import ballerina/file;

public function main() returns error? {
    check from var entry in check file:readDir("")
          do {

          };
}
MaryamZi commented 1 year ago

Can we close this since it isn't a bug?

    from var entry in check file:readDir(SOURCE_DIR)
          do {

          };
manuranga commented 1 year ago

I remember it worked when I moved check file:readDir(SOURCE_DIR) to the previous line. Could be misremembering. Please close if it work.