rokucommunity / brighterscript

A superset of Roku's BrightScript language
MIT License
152 stars 47 forks source link

Error BS1091 Incorrectly Flags "#if not <CONST>" #1158

Open shortad opened 2 months ago

shortad commented 2 months ago

Pretty simple to test in any app, see the screenshot.

I've had one of these #if nots in our repo for a long time, but I did a quick sanity test too and verified that the Roku OS can process either if/else path successfully.

image

shortad commented 2 months ago

Line Source: https://github.com/rokucommunity/brighterscript/blob/4bd4a5f818019b5d39fb6a4a527e47ad3af20d31/src/preprocessor/Preprocessor.ts#L183

Possible Fix (throwing this out there at 6:40am, so take with salt):

  case TokenKind.Identifier:
    // added replaceAll to remove 1 or more "not"
    const nameLower = token.text?.toLowerCase().replaceAll("not ", "");

    if (this.constants.has(nameLower)) {
      return !!this.constants.get(nameLower);
    }