Skip to content

enable flag value type checking - #11311

Merged
amtoine merged 2 commits into
nushell:mainfrom
WindSoilder:flag_type_checking
Dec 20, 2023
Merged

amtoine merged 2 commits into
nushell:mainfrom
WindSoilder:flag_type_checking

Conversation

@WindSoilder

Copy link
Copy Markdown
Contributor

Description

Fixes: #11310

User-Facing Changes

After the change, the following code will go to error:

> def a [--x: int = 3] { "aa" }
> let y = "aa"
> a --x=$y
Error: nu::parser::type_mismatch

  × Type mismatch.
   ╭─[entry #32:2:1]
 2 │ let y = "aa"
 3 │ a --x=$y
   ·       ─┬
   ·        ╰── expected int, found string
   ╰────

@WindSoilder WindSoilder changed the title make flag type checking enable flag value type checking Dec 13, 2023
@sholderbach sholderbach added the A:type-system Problems or features related to nushell's type system label Dec 13, 2023

@amtoine amtoine left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is perfect 👌

i could reproduce the bug using the snippet in the new test with current Nushell and it's gone with this PR, thanks @WindSoilder 🙏
this is all getting better and better 😇

@amtoine
amtoine merged commit 697f3c0 into nushell:main Dec 20, 2023
dmatos2012 pushed a commit to dmatos2012/nushell that referenced this pull request Feb 20, 2024
# Description
Fixes: nushell#11310

# User-Facing Changes
After the change, the following code will go to error:
```nushell
> def a [--x: int = 3] { "aa" }
> let y = "aa"
> a --x=$y
Error: nu::parser::type_mismatch

  × Type mismatch.
   ╭─[entry nushell#32:2:1]
 2 │ let y = "aa"
 3 │ a --x=$y
   ·       ─┬
   ·        ╰── expected int, found string
   ╰────
```
@WindSoilder
WindSoilder deleted the flag_type_checking branch February 27, 2024 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:type-system Problems or features related to nushell's type system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nushell doesn't raise error if we pass incorrect flag value type

3 participants