Closed maxim-uvarov closed 2 months ago
I get this on Windows. Note, the gray boxes are just showing where there are spaces.
Seems like it's just like yours. I wonder why it's missing. It doesn't have the outer {}
at all. I kind of wonder if this is by design or not because it doesn't have every character listed in the string.
My guess is that it's only reporting items that have a span and maybe some of the syntax doesn't have spans. I'm not really sure.
A more verbose way of looking at the ast is
ast "match 3 { 1 => { 'yes!' }, _ => { 'no!' } }"
I wonder if it skips some characters too?
Edit: Seem to do the same thing.
I think it's happening somewhere in here. https://github.com/nushell/nushell/blob/1cdc39bc2a616fde4c2b58b45893653517725643/crates/nu-parser/src/flatten.rs#L220-L246
@fdncred I don't know how to read it 🙈
ast "match 3 { 1 => { 'yes!' }, _ => { 'no!' } }" | get block
Block {
signature: Signature {
name: "",
usage: "",
extra_usage: "",
search_terms: [],
required_positional: [],
optional_positional: [],
rest_positional: None,
named: [],
input_output_types: [],
allow_variants_without_examples: false,
is_filter: false,
creates_scope: false,
allows_unknown_args: false,
category: Default,
},
pipelines: [
Pipeline {
elements: [
PipelineElement {
pipe: None,
expr: Expression {
expr: Call(
Call {
decl_id: 30,
head: Span {
start: 1989120,
end: 1989125,
},
arguments: [
Positional(
Expression {
expr: Int(
3,
),
span: Span {
start: 1989126,
end: 1989127,
},
ty: Int,
custom_completion: None,
},
),
Positional(
Expression {
expr: MatchBlock(
[
(
MatchPattern {
pattern: Value(
Expression {
expr: Int(
1,
),
span: Span {
start: 1989130,
end: 1989131,
},
ty: Int,
custom_completion: None,
},
),
guard: None,
span: Span {
start: 1989130,
end: 1989131,
},
},
Expression {
expr: Block(
5756,
),
span: Span {
start: 1989135,
end: 1989145,
},
ty: Block,
custom_completion: None,
},
),
(
MatchPattern {
pattern: IgnoreValue,
guard: None,
span: Span {
start: 1989147,
end: 1989148,
},
},
Expression {
expr: Block(
5757,
),
span: Span {
start: 1989152,
end: 1989161,
},
ty: Block,
custom_completion: None,
},
),
],
),
span: Span {
start: 1989128,
end: 1989163,
},
ty: Any,
custom_completion: None,
},
),
],
parser_info: {},
},
),
span: Span {
start: 1989120,
end: 1989163,
},
ty: Any,
custom_completion: None,
},
redirection: None,
},
],
},
],
captures: [],
redirect_env: false,
span: Some(
Span {
start: 1989120,
end: 1989163,
},
),
}
Seems like it's just like yours.
Seems like my Mac has been acting weird on its own in the last few days :(
I didn't change anything inside the nushell sources, just built from some commit from main
.
@fdncred I don't know how to read it 🙈
This is the debug details of the nushell ast with object names that are used in the source code itself.
I'm guessing all this is working as expected right now. I'm not positive why some things show up and others do not other than looking at the code I linked to and investigating further.
I would say this is down to how we implement the AST for match
at the moment. It is not really a traditional shape_block
but rather the special syntax form for all the following match arms.
Note how the =>
match arm syntax token also isn't part of the output.
The output may be suboptimal if you want to do work on the nu --ide-ast
stuff, but there is no hard requirement how this has to look. We will probably draw somewhat different AST boundaries for https://github.com/nushell/new-nu-parser
Describe the bug
nu --ide-ast
is missing an opening '{' aftermatch
How to reproduce
Expected behavior
I expect
nu --ide-ast
to output all the symbols without skipping themScreenshots
No response
Configuration
Additional context
No response