forked from extern/nushell
Limit recursion to avoid stack overflow (#7657)
Add recursion limit to `def` and `block`. Summary of this PR , it will detect if `def` call itself or not . Then execute by using `stack` which I think best choice to use with this design and core as it is available in all crates and mutable and calculate the recursion limit on calling `def`. Set 50 as recursion limit on `Config`. Add some tests too . Fixes #5899 Co-authored-by: Reilly Wood <reilly.wood@icloud.com>
This commit is contained in:
committed by
GitHub
parent
9bc4e6794d
commit
00469de93e
@@ -11,6 +11,7 @@ pub struct Block {
|
||||
pub captures: Vec<VarId>,
|
||||
pub redirect_env: bool,
|
||||
pub span: Option<Span>, // None option encodes no span to avoid using test_span()
|
||||
pub recursive: Option<bool>, // does the block call itself?
|
||||
}
|
||||
|
||||
impl Block {
|
||||
@@ -51,6 +52,7 @@ impl Block {
|
||||
captures: vec![],
|
||||
redirect_env: false,
|
||||
span: None,
|
||||
recursive: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,6 +68,7 @@ where
|
||||
captures: vec![],
|
||||
redirect_env: false,
|
||||
span: None,
|
||||
recursive: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user