[−][src]Struct rslint_core::groups::errors::NoUnsafeFinally
Forbid the use of unsafe control flow statements in try and catch blocks.
JavaScript suspends any running control flow statements inside of try
and catch
blocks until
finally
is done executing. This means that any control statements such as return
, throw
, break
,
and continue
which are used inside of a finally
will override any control statements in try
and catch
.
This is almost always unexpected behavior.
Incorrect Code Examples
// We expect 10 to be returned, but 5 is actually returned
function foo() {
try {
return 10;
// ^^^^^^^^^ this statement is executed, but actually returning is paused...
} finally {
return 5;
// ^^^^^^^^^ ...finally is executed, and this statement returns from the function, **the previous is ignored**
}
}
foo() // 5
Throwing errors inside try statements
// We expect an error to be thrown, then 5 to be returned, but the error is not thrown
function foo() {
try {
throw new Error("bar");
// ^^^^^^^^^^^^^^^^^^^^^^^ this statement is executed but throwing the error is paused...
} finally {
return 5;
// ^^^^^^^^^ ...we expect the error to be thrown and then for 5 to be returned,
// but 5 is returned early, **the error is not thrown**.
}
}
foo() // 5
Implementations
impl NoUnsafeFinally
[src]
Trait Implementations
impl Clone for NoUnsafeFinally
[src]
fn clone(&self) -> NoUnsafeFinally
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl CstRule for NoUnsafeFinally
[src]
fn check_node(&self, node: &SyntaxNode, ctx: &mut RuleCtx) -> Option<()>
[src]
fn check_token(&self, token: &SyntaxToken, ctx: &mut RuleCtx) -> Option<()>
[src]
fn check_root(&self, root: &SyntaxNode, ctx: &mut RuleCtx) -> Option<()>
[src]
impl Debug for NoUnsafeFinally
[src]
impl Default for NoUnsafeFinally
[src]
fn default() -> NoUnsafeFinally
[src]
impl<'de> Deserialize<'de> for NoUnsafeFinally
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Rule for NoUnsafeFinally
[src]
impl Serialize for NoUnsafeFinally
[src]
Auto Trait Implementations
impl RefUnwindSafe for NoUnsafeFinally
impl Send for NoUnsafeFinally
impl Sync for NoUnsafeFinally
impl Unpin for NoUnsafeFinally
impl UnwindSafe for NoUnsafeFinally
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> DynClone for T where
T: Clone,
[src]
T: Clone,
impl<T> Erasable for T
unsafe fn unerase(this: NonNull<Erased>) -> NonNull<T>
const ACK_1_1_0: bool
fn erase(this: NonNull<Self>) -> NonNull<Erased>
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Serialize for T where
T: Serialize + ?Sized,
[src]
T: Serialize + ?Sized,
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,