Commit 3c83ea7
authored
Allow variables in columns of table literals (nushell#16669)
Fixes nushell#15333
This should bring things more in line with how records work. Turns out
it was already be parsed properly, it was just the type check code
causing problems. If a column name isn't a literal then we just don't
add that column to type at parse-time.
+3 tests
## Release notes summary - What our users need to know
### Table literal columns support variables
Table literals can now have variables in the column names list. For
example, this is now allowed:
```nushell
let column_name = 'column0'
[[ $column_name column1 ];
[ foo bar ]
[ baz car ]
[ far fit ]]
# => ╭───┬─────────┬─────────╮
# => │ # │ column0 │ column1 │
# => ├───┼─────────┼─────────┤
# => │ 0 │ foo │ bar │
# => │ 1 │ baz │ car │
# => │ 2 │ far │ fit │
# => ╰───┴─────────┴─────────╯
```
<details>
<summary>ANSI code block</summary>
```ansi
�[38;5;6m> �[1;36mlet �[0m�[35mcolumn_name �[39m= �[32m'column0'�[0m
�[1;34m[[ �[0m�[35m$column_name �[32mcolumn1 �[1;34m];�[0m
�[1;34m[ �[0m�[32mfoo bar �[1;34m]�[0m
�[1;34m[ �[0m�[32mbaz car �[1;34m]�[0m
�[1;34m[ �[0m�[32mfar fit �[1;34m]]�[0m
�[39m╭───┬─────────┬─────────╮�[0m
�[39m│ �[1;32m# �[0m�[39m│ �[1;32mcolumn0 �[0m�[39m│ �[1;32mcolumn1 �[0m�[39m│�[0m
�[39m├───┼─────────┼─────────┤�[0m
�[39m│ �[1;32m0 �[0m�[39m│ foo │ bar │�[0m
�[39m│ �[1;32m1 �[0m�[39m│ baz │ car │�[0m
�[39m│ �[1;32m2 �[0m�[39m│ far │ fit │�[0m
�[39m╰───┴─────────┴─────────╯�[0m
```
</details>1 parent f102448 commit 3c83ea7
2 files changed
+42
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4806 | 4806 | | |
4807 | 4807 | | |
4808 | 4808 | | |
4809 | | - | |
4810 | | - | |
4811 | | - | |
4812 | | - | |
| 4809 | + | |
| 4810 | + | |
| 4811 | + | |
4813 | 4812 | | |
4814 | | - | |
| 4813 | + | |
| 4814 | + | |
| 4815 | + | |
4815 | 4816 | | |
4816 | 4817 | | |
4817 | 4818 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1051 | 1051 | | |
1052 | 1052 | | |
1053 | 1053 | | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
0 commit comments