Skip to content

type-check default values of list annotations#8600

Merged
sophiajt merged 5 commits intonushell:mainfrom
1Kinoti:main
Mar 24, 2023
Merged

type-check default values of list annotations#8600
sophiajt merged 5 commits intonushell:mainfrom
1Kinoti:main

Conversation

@1Kinoti
Copy link
Copy Markdown
Contributor

@1Kinoti 1Kinoti commented Mar 24, 2023

Description

@fdncred noticed an issue with list annotations that while i was trying to find a fix found another issue.

innitially, this was accepted by the parser

def err [list: list<int> = ['a' 'b' 'c']] {}

but now an error is raised

Error: nu::parser::assignment_mismatch

  × Default value wrong type
   ╭─[entry #1:1:1]
 1 │ def err [list: list<int> = ['a' 'b' 'c']] {}
   ·                            ──────┬────
   ·                                   ╰── expected default value to be `list<int>`
   ╰────

User-Facing Changes

none

Tests + Formatting

done

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Mar 24, 2023

quick fix. nice!

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2023

Codecov Report

Merging #8600 (2d8aa79) into main (f66136b) will decrease coverage by 0.39%.
The diff coverage is 91.66%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8600      +/-   ##
==========================================
- Coverage   68.54%   68.15%   -0.39%     
==========================================
  Files         631      631              
  Lines      101895   101910      +15     
==========================================
- Hits        69839    69459     -380     
- Misses      32056    32451     +395     
Impacted Files Coverage Δ
crates/nu-parser/src/parser.rs 83.65% <91.66%> (+0.04%) ⬆️

... and 5 files with indirect coverage changes

@sophiajt sophiajt merged commit 744a28b into nushell:main Mar 24, 2023
@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Mar 24, 2023

This is closer I think but what about this scenario? I'm confused by it.

> def run [list: list<string> = [a b c]] { $list }
> run
╭───┬───╮
│ 0 │ a │
│ 1 │ b │
│ 2 │ c │
╰───┴───╯
> run | describe
list<string>
> run [1 2 3]
╭───┬───╮
│ 0 │ 1 │
│ 1 │ 2 │
│ 2 │ 3 │
╰───┴───╯
> run [1 2 3] | describe
list<string>
> [1 2 3] | describe
list<int>

For some reason run [1 2 3] thinks the [1 2 3] is a list<string> but I'm not sure why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants