-
Notifications
You must be signed in to change notification settings - Fork 334
Allow multiline if then else
#14522
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
Open
JaroslavTulach
wants to merge
5
commits into
develop
Choose a base branch
from
wip/jtulach/MultiLineIfThenElse6408
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Allow multiline if then else
#14522
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if then else
jdunkerley
approved these changes
Dec 18, 2025
Member
jdunkerley
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do a patch release we may need to include this as I expect libs will use it pretty quickly :)
Thank you and @kazcw for enabling this
GregoryTravis
approved these changes
Dec 18, 2025
JaroslavTulach
commented
Dec 21, 2025
| let new_line = | ||
| block::Line { newline: line.newline.into(), expression: None }; | ||
| block_lines[i - 1] = new_prev_line; | ||
| block_lines[i] = new_line; |
Member
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- the 48731d4 commit tries to implement the same idea as has previously been done in
TreeToIr - if 48731d4 gets polished, then 571f21a will not be needed
- right now the
Tree::multi_segment_app(all_segments)manual manipulation results in assertion error:
thread 'if_block_else_block' panicked at lib/rust/parser/src/source/span.rs:204:13:
assertion `left == right` failed
left: Location { utf8: 18, utf16: 18, line: 1, col16: 5 }
right: Location { utf8: 19, utf16: 19, line: 2, col16: 0 }
stack backtrace:
0: __rustc::rust_begin_unwind
at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/std/src/panicking.rs:697:5
1: core::panicking::panic_fmt
at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/panicking.rs:75:14
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
at /.rustup/toolchains/1.90.0-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/panicking.rs:403:5
4: enso_parser::source::span::Span::concat
at enso/lib/rust/parser/src/source/span.rs:204:13
5: <enso_parser::syntax::token::Token<T> as enso_parser::source::span::Builder>::add_to_span
at enso/lib/rust/parser/src/source/span.rs:339:18
6: enso_parser::source::span::Span::add
at enso/lib/rust/parser/src/source/span.rs:179:9
7: <enso_parser::syntax::tree::MultiSegmentAppSegment as enso_parser::source::span::Builder>::add_to_span
at enso/lib/rust/parser/src/syntax/tree.rs:822:14
8: <enso_prelude::data::non_empty_vec::NonEmptyVec<T> as enso_parser::source::span::Builder>::add_to_span::{{closure}}
at enso/lib/rust/parser/src/source/span.rs:377:53
9: <core::slice::iter::IterMut<T> as core::iter::traits::iterator::Iterator>::fold
at /.rustup/toolchains/1.90.0-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/slice/iter/macros.rs:255:27
10: <enso_prelude::data::non_empty_vec::NonEmptyVec<T> as enso_parser::source::span::Builder>::add_to_span
at enso/lib/rust/parser/src/source/span.rs:377:26
11: enso_parser::source::span::Span::add
at enso/lib/rust/parser/src/source/span.rs:179:9
12: enso_parser::syntax::tree::Tree::multi_segment_app
at enso/lib/rust/parser/src/source/span.rs:300:63
13: enso_parser::syntax::statement::compound_lines_maybe_with_tail
at enso/lib/rust/parser/src/syntax/statement.rs:149:47
14: enso_parser::syntax::statement::compound_lines_with_tail
at enso/lib/rust/parser/src/syntax/statement.rs:88:5
15: enso_parser::syntax::statement::BodyBlockParser::parse_body_block
at enso/lib/rust/parser/src/syntax/statement.rs:47:26
16: enso_parser::syntax::tree::block::parse_block
at enso/lib/rust/parser/src/syntax/tree/block.rs:60:32
17: <enso_parser::macros::resolver::ResolverState as enso_parser::syntax::expression::consumer::Finish>::finish
at enso/lib/rust/parser/src/macros/resolver.rs:178:17
18: <enso_parser::macros::resolver::Resolver as enso_parser::syntax::expression::consumer::Finish>::finish
at enso/lib/rust/parser/src/macros/resolver.rs:252:23
19: <enso_parser::lexer::Lexer<Inner> as enso_parser::syntax::expression::consumer::Finish>::finish
at enso/lib/rust/parser/src/lexer.rs:1403:32
20: enso_parser::Parser::run
at enso/lib/rust/parser/src/lib.rs:178:80
21: enso_parser::Parser::parse_block
at enso/lib/rust/parser/src/lib.rs:173:14
22: enso_parser_debug::test::parse_block
at ./src/test.rs:61:42
23: parse::if_block_else_block
at ./tests/parse.rs:33:45
24: parse::if_block_else_block::{{closure}}
at ./tests/parse.rs:114:25
25: core::ops::function::FnOnce::call_once
at /.rustup/toolchains/1.90.0-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:253:5
26: core::ops::function::FnOnce::call_once
at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/ops/function.rs:253:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
test if_block_else_block ... FAILED
- probably some locations aren't quite right yet
- concatenating Trees from multiple lines without including the newline isn't being liked...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Description
if then elselikeif-then-else#6408Important Notes
IfThenElseIR instead ofif_then_elsefunction invocation #11365 supportIfThenElsewithout else branchelseapplicationChecklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Java,
Rust