mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
add type check during eval time (#11475)
# Description Fixes: #11438 Take the following as example: ```nushell def spam [foo: string] { $'foo: ($foo | describe)' } def outer [--foo: string] { spam $foo } outer ``` When we call `outer`, type checker only check the all for `outer`, but doesn't check inside the body of `outer`. This pr is trying to introduce a type checking process through `Type::is_subtype()` during eval time. ## NOTE I'm not really sure if it's easy to make a check inside the body of `outer`. Adding an eval time type checker seems like an easier solution. As a result: `outer` will be caught by runtime, not parse time type checker cc @kubouch # User-Facing Changes After this pr the following call will failed: ```nushell > outer Error: nu:🐚:cant_convert × Can't convert to string. ╭─[entry #27:1:1] 1 │ def outer [--foo: any] { 2 │ spam $foo · ──┬─ · ╰── can't convert nothing to string 3 │ } ╰──── ``` # Tests + Formatting Done # After Submitting NaN
This commit is contained in:
@ -185,6 +185,7 @@ export def critical [
|
||||
--short (-s) # Whether to use a short prefix
|
||||
--format (-f): string # A format (for further reference: help std log)
|
||||
] {
|
||||
let format = $format | default ""
|
||||
handle-log $message (log-types | get CRITICAL) $format $short
|
||||
}
|
||||
|
||||
@ -194,6 +195,7 @@ export def error [
|
||||
--short (-s) # Whether to use a short prefix
|
||||
--format (-f): string # A format (for further reference: help std log)
|
||||
] {
|
||||
let format = $format | default ""
|
||||
handle-log $message (log-types | get ERROR) $format $short
|
||||
}
|
||||
|
||||
@ -203,6 +205,7 @@ export def warning [
|
||||
--short (-s) # Whether to use a short prefix
|
||||
--format (-f): string # A format (for further reference: help std log)
|
||||
] {
|
||||
let format = $format | default ""
|
||||
handle-log $message (log-types | get WARNING) $format $short
|
||||
}
|
||||
|
||||
@ -212,6 +215,7 @@ export def info [
|
||||
--short (-s) # Whether to use a short prefix
|
||||
--format (-f): string # A format (for further reference: help std log)
|
||||
] {
|
||||
let format = $format | default ""
|
||||
handle-log $message (log-types | get INFO) $format $short
|
||||
}
|
||||
|
||||
@ -221,6 +225,7 @@ export def debug [
|
||||
--short (-s) # Whether to use a short prefix
|
||||
--format (-f): string # A format (for further reference: help std log)
|
||||
] {
|
||||
let format = $format | default ""
|
||||
handle-log $message (log-types | get DEBUG) $format $short
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user