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

Test calling methods on parentheses with binary operators #74

Merged
merged 2 commits into from
Mar 24, 2020

Conversation

generalmimon
Copy link
Member

@generalmimon generalmimon commented Jan 30, 2020

I noticed that the KSC doesn't always wrap expressions in parentheses where neccessary. For instance, (str_a + str_b).substring(3, 9) generates the same code as str_a + str_b.substring(3, 9) for most languages. It's low priority, but it's clearly a bug in the compiler and should be fixed.

If the bug will take effect or not depends on the actual implementation in the target language, so I think it's wise to add a test for it to see where it works and where not.

kaitai-io/kaitai_struct#69 is related. Simply put, sometimes there are unnecessarily many brackets and sometimes too little. However, unless the compiler is 100% sure that the brackets are useless, it's always better to include them.

@generalmimon generalmimon changed the title Test methods on expressions with binary operators in parens Test calling methods on parentheses with binary operators Jan 30, 2020
@GreyCat
Copy link
Member

GreyCat commented Mar 24, 2020

There has been a effort long ago and relevant branch to do it in more optimal way. Unfortunately, I wasn't very successful with finishing that work, and never got the chance to return to it.

I think that this one still works good, at least exposing all these problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants