mirror of
https://github.com/nushell/nushell
synced 2025-01-14 14:14:13 +00:00
Add test
This commit is contained in:
parent
c2be740ad4
commit
b82a4869d5
2 changed files with 11 additions and 0 deletions
|
@ -2101,6 +2101,12 @@ impl<'a> ParserWorkingSet<'a> {
|
|||
.expect("internal error: expected def name");
|
||||
|
||||
self.enter_scope();
|
||||
// FIXME: because parse_signature will update the scope with the variables it sees
|
||||
// we end up parsing the signature twice per def. The first time is during the predecl
|
||||
// so that we can see the types that are part of the signature, which we need for parsing.
|
||||
// The second time is when we actually parse the body itself.
|
||||
// We can't reuse the first time because the variables that are created during parse_signature
|
||||
// are lost when we exit the scope below.
|
||||
let (sig, ..) = self.parse_signature(spans[2]);
|
||||
let mut signature = sig
|
||||
.as_signature()
|
||||
|
|
|
@ -118,3 +118,8 @@ fn simple_var_closing() -> TestResult {
|
|||
fn predecl_check() -> TestResult {
|
||||
run_test("def bob [] { sam }; def sam [] { 3 }; bob", "3")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn def_with_no_dollar() -> TestResult {
|
||||
run_test("def bob [x] { $x + 3 }; bob 4", "7")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue