refactor: tree-sitter-nu friendly alternative expressions (#15301)

# Description

Choose more tree-sitter-nu-friendly (if not better) expressions in nu
scripts.
The changes made in this PR all come from known issues of
`tree-sitter-nu`.

1. nested single/double quotes:
https://github.com/nushell/tree-sitter-nu/issues/125
2. module path of `use` command:
https://github.com/nushell/tree-sitter-nu/issues/165
3. where predicates of boolean column:
https://github.com/nushell/tree-sitter-nu/issues/177
4. `error make` keyword:
https://github.com/nushell/tree-sitter-nu/issues/179

Those issues are either hard to fix or "not planned" for syntactical
precision considerations ATM.

# User-Facing Changes

Should be none

# Tests + Formatting

# After Submitting
This commit is contained in:
zc he
2025-03-12 21:48:19 +08:00
committed by GitHub
parent a17ffdfe56
commit 44b7cfd696
5 changed files with 11 additions and 11 deletions

View File

@ -55,7 +55,7 @@ export def aggregate [
}
}
def "error not-a-table" [span: record<start: int, end:int>] {
def "error-make not-a-table" [span: record<start: int, end:int>] {
error make {
msg: "input must be a table",
label: {
@ -69,9 +69,9 @@ export def aggregate [
let IN = $in
let md = metadata $in
let first = try { $IN | first } catch { error not-a-table $md.span }
let first = try { $IN | first } catch { error-make not-a-table $md.span }
if not (($first | describe) starts-with record) {
error not-a-table $md.span
error-make not-a-table $md.span
}
let grouped = "items" in $first