Skip to content

don't allow break/continue in each and items command#13398

Merged
devyn merged 5 commits intonushell:mainfrom
WindSoilder:break
Jul 19, 2024
Merged

don't allow break/continue in each and items command#13398
devyn merged 5 commits intonushell:mainfrom
WindSoilder:break

Conversation

@WindSoilder
Copy link
Copy Markdown
Contributor

Description

Fixes: #11451

User-Facing Changes

Before

 [1 2 3] | each {|e| break; print $e }
╭────────────╮
 empty list 
╰────────────╯

After

❯ [1 2 3] | each {|e| break; print $e }
Error: nu::shell::eval_block_with_input

  × Eval block failed with pipeline input
   ╭─[entry #9:1:2]
 1 │ [1 2 3] | each {|e| break; print $e }
   ·  ┬
   ·  ╰── source value
   ╰────

Error:   × Break used outside of loop
   ╭─[entry #9:1:21]
 1 │ [1 2 3] | each {|e| break; print $e }
   ·                     ──┬──
   ·                       ╰── used outside of loop
   ╰────

Tests + Formatting

Removes some tests.

@WindSoilder WindSoilder added the deprecated:pr-language (deprecated: this label is too vague) This PR makes some language changes label Jul 17, 2024
Copy link
Copy Markdown
Contributor

@devyn devyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good, the IR generation is already a bit weird when there's no loop target found, we have to generate a real call to continue/break, so this frees us up from absolutely having to do that

@WindSoilder WindSoilder changed the title don't allow break in each and items command don't allow break/continue in each and items command Jul 18, 2024
@devyn
Copy link
Copy Markdown
Contributor

devyn commented Jul 19, 2024

Okay, let's do it

@devyn devyn merged commit e8764de into nushell:main Jul 19, 2024
@hustcer hustcer added this to the v0.96.0 milestone Jul 19, 2024
@devyn devyn added the notes:breaking-changes This PR implies a change affecting users and has to be noted in the release notes label Jul 21, 2024
@WindSoilder WindSoilder deleted the break branch October 14, 2024 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deprecated:pr-language (deprecated: this label is too vague) This PR makes some language changes notes:breaking-changes This PR implies a change affecting users and has to be noted in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

break weird behaviour

3 participants