Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser error in func()[subscript] = value;, needs extra parentheses #114

Open
armoha opened this issue Jun 12, 2023 · 0 comments
Open

Parser error in func()[subscript] = value;, needs extra parentheses #114

armoha opened this issue Jun 12, 2023 · 0 comments
Labels
P-high High priority

Comments

@armoha
Copy link
Owner

armoha commented Jun 12, 2023

// epScript example
function onPluginStart() {
    const X = EUDArray(10);
    foreach (i : py_range(10)) {
        X[i] = EUDArray(10);
    }

    // ▽ generates mistyped function since 0.8.2.4 to 0.9.9.7. (fixed in euddraft 0.9.9.8)
    const x2 = function (index) : EUDArray { return X[index]; };

    x2(2)[3] = 4;  // General syntax error
    (x2(2))[3] = 4;  // Okay
}

Why hard to fix?

epScript has 'return value selection' syntax:

const foo = function () { return 0, 1, 2, 3; };

const zero = foo()[[0]];  // choose 0th return value
const one, two = foo()[[1, 2]];  // choose 1st and 2nd return values
const three = foo()[[3]];

and epScript also has array-init expression:

const a = [1, 2, 3];  // declare 3-sized array and initialize it with 1, 2 and 3

const bar = foo (arr: EUDArray) { return arr[0]; };
bar([0, 1, 2, 3]);  // okay, returns 0

If func(arg)[subscript] = value; were allowed, there should be syntax ambiguity:

foo()[[0]];
// can be interpreted in 2 ways:
// (1) choose 0th value
// (2) subscript with 1-sized array initialized with 0
@armoha armoha added wontfix This will not be worked on P-high High priority labels Jun 12, 2023
@armoha armoha changed the title Parser error in func()[subscript] = value; Parser error in func()[subscript] = value;, needs extra parentheses Jun 12, 2023
@armoha armoha removed the wontfix This will not be worked on label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-high High priority
Projects
None yet
Development

No branches or pull requests

1 participant