Skip to content

Commit d7b5eb3

Browse files
committed
fix adjacent operator error
1 parent 8438349 commit d7b5eb3

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

Resources/OSL Utils.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ class OSLLinter {
682682
const token = tokens[i];
683683
const nextToken = tokens[i + 1];
684684

685-
if (token.type === 'operator' && nextToken.type === 'operator' && !['-', '!'].includes(nextToken.value)) {
685+
if (token.type === 'operator' && nextToken.type === 'operator' && !['-', '!', '?', '~'].includes(nextToken.value)) {
686686
const combined = token.value + nextToken.value;
687687

688688
const explicitlyAllowed = new Set(['++', '--', '::']);
@@ -4364,9 +4364,25 @@ if (typeof Scratch !== "undefined") {
43644364
let utils = new OSLUtils();
43654365
const fs = require("fs");
43664366

4367-
const code = 'state.folder_sidebar = !state.folder_sidebar'
4368-
4369-
const result = utils.generateFullAST({CODE: code});
4367+
const code = `def funcThatMightError() (
4368+
if random(1, 2) == 1 (
4369+
throw "error" "lmao so goob"
4370+
)
4371+
return "lmao"
4372+
)
4373+
4374+
result test @= ?funcThatMightError()
4375+
if test.isOk() (
4376+
log test.unwrap()
4377+
// "lmao"
4378+
) else (
4379+
log test.unwrapErr()
4380+
// "lmao so goob"
4381+
)`
4382+
4383+
console.log(code)
4384+
4385+
const result = utils.lintSyntax({CODE: code}).errors;
43704386

43714387
fs.writeFileSync("lol.json", JSON.stringify(result, null, 2));
43724388
}

0 commit comments

Comments
 (0)