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

[BUG] Error when block only has comment statements it produces invalid Bash code #599

Open
Ph0enixKM opened this issue Nov 16, 2024 · 0 comments
Labels
bug Something isn't working compiler

Comments

@Ph0enixKM
Copy link
Member

Describe the bug
When a Block (the syntax module modules/block.rs) parses any positive amount of comments without any other statements, it does not insert a noop command :. Comments are not commands that Bash parses, so it omits all of them and looks for some command. If none found - it fails, which is an unwanted behaviour. To mitigate the problem, Bash developers use so called noop operator (:) that does nothing.

To Reproduce
Write a loop, if statement or function declaration with a block that only contains comment(s).

Expected behavior
Block

{
  // Comment 1
  // Comment 2
}

Should compile to

{
  # Comment 1
  # Comment 2
  :
}
@Ph0enixKM Ph0enixKM added the bug Something isn't working label Nov 16, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in Amber Project Nov 16, 2024
@Mte90 Mte90 added the compiler label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler
Projects
None yet
Development

No branches or pull requests

2 participants