From 3f5c714f3c4d88acebb20f512045c9cee7f80f88 Mon Sep 17 00:00:00 2001 From: Erik Demaine Date: Mon, 20 Sep 2021 00:17:58 -0400 Subject: [PATCH 1/3] Improve documentation of jumps --- lib/coffeescript/nodes.js | 11 ++++++----- src/nodes.coffee | 13 +++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/coffeescript/nodes.js b/lib/coffeescript/nodes.js index 2af920a22b..c9e1ee7357 100644 --- a/lib/coffeescript/nodes.js +++ b/lib/coffeescript/nodes.js @@ -616,11 +616,12 @@ // has special awareness of how to handle comments within its output. Base.prototype.includeCommentFragments = NO; - // `jumps` tells you if an expression, or an internal part of an expression - // has a flow control construct (like `break`, or `continue`, or `return`, - // or `throw`) that jumps out of the normal flow of control and can’t be - // used as a value. This is important because things like this make no sense; - // we have to disallow them. + // `jumps` tells you if an expression, or an internal part of an expression, + // has a flow control construct (like `break`, `continue`, or `return`) + // that jumps out of the normal flow of control and can’t be used as a value. + // (Note that `throw` is not considered a flow control construct.) + // This is important because flow control in the middle of an expression + // make no sense; we have to disallow them. Base.prototype.jumps = NO; // If `node.shouldCache() is false`, it is safe to use `node` more than once. diff --git a/src/nodes.coffee b/src/nodes.coffee index ca0b711d5b..1bb9c6eba9 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -392,11 +392,12 @@ exports.Base = class Base # has special awareness of how to handle comments within its output. includeCommentFragments: NO - # `jumps` tells you if an expression, or an internal part of an expression - # has a flow control construct (like `break`, or `continue`, or `return`, - # or `throw`) that jumps out of the normal flow of control and can’t be - # used as a value. This is important because things like this make no sense; - # we have to disallow them. + # `jumps` tells you if an expression, or an internal part of an expression, + # has a flow control construct (like `break`, `continue`, or `return`) + # that jumps out of the normal flow of control and can’t be used as a value. + # (Note that `throw` is not considered a flow control construct.) + # This is important because flow control in the middle of an expression + # make no sense; we have to disallow them. jumps: NO # If `node.shouldCache() is false`, it is safe to use `node` more than once. @@ -4996,7 +4997,7 @@ exports.Catch = class Catch extends Base isStatement: YES - jumps: (o) -> @recovery.jumps(o) + jumps: (o) -> @recovery.jumps o makeReturn: (results, mark) -> ret = @recovery.makeReturn results, mark From 79830dcb9cbd5667bdfe8ffd87ca713c0c29ae7b Mon Sep 17 00:00:00 2001 From: Erik Demaine Date: Mon, 20 Sep 2021 00:46:09 -0400 Subject: [PATCH 2/3] Review suggestion Co-authored-by: Geoffrey Booth <456802+GeoffreyBooth@users.noreply.github.com> --- src/nodes.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nodes.coffee b/src/nodes.coffee index 1bb9c6eba9..172de2d174 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -397,7 +397,7 @@ exports.Base = class Base # that jumps out of the normal flow of control and can’t be used as a value. # (Note that `throw` is not considered a flow control construct.) # This is important because flow control in the middle of an expression - # make no sense; we have to disallow them. + # makes no sense; we have to disallow it. jumps: NO # If `node.shouldCache() is false`, it is safe to use `node` more than once. From 187e8a17a3d3c82fd066f1c23e042fdbb10de3fc Mon Sep 17 00:00:00 2001 From: Erik Demaine Date: Mon, 20 Sep 2021 01:08:01 -0400 Subject: [PATCH 3/3] Rebuild --- lib/coffeescript/nodes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coffeescript/nodes.js b/lib/coffeescript/nodes.js index c9e1ee7357..569d235abc 100644 --- a/lib/coffeescript/nodes.js +++ b/lib/coffeescript/nodes.js @@ -621,7 +621,7 @@ // that jumps out of the normal flow of control and can’t be used as a value. // (Note that `throw` is not considered a flow control construct.) // This is important because flow control in the middle of an expression - // make no sense; we have to disallow them. + // makes no sense; we have to disallow it. Base.prototype.jumps = NO; // If `node.shouldCache() is false`, it is safe to use `node` more than once.