diff --git a/examples/in_as_expression.html.erb b/examples/in_as_expression.html.erb
new file mode 100644
index 000000000..0e686190f
--- /dev/null
+++ b/examples/in_as_expression.html.erb
@@ -0,0 +1,7 @@
+
+ <% if 1 in Numeric %>
+
Text1
+ <% else %>
+
Text2
+ <% end %>
+
diff --git a/src/analyze/analyze_helpers.c b/src/analyze/analyze_helpers.c
index 7a54577f4..b0d6f2b1b 100644
--- a/src/analyze/analyze_helpers.c
+++ b/src/analyze/analyze_helpers.c
@@ -277,7 +277,13 @@ bool search_in_nodes(const pm_node_t* node, void* data) {
analyzed_ruby_T* analyzed = (analyzed_ruby_T*) data;
if (node->type == PM_IN_NODE) { analyzed->in_node_count++; }
- if (node->type == PM_MATCH_PREDICATE_NODE) { analyzed->in_node_count++; }
+ if (node->type == PM_CASE_MATCH_NODE) {
+ const pm_case_match_node_t* case_match_node = (const pm_case_match_node_t*) node;
+
+ if (case_match_node->predicate != NULL && case_match_node->predicate->type == PM_MATCH_PREDICATE_NODE) {
+ analyzed->in_node_count++;
+ }
+ }
pm_visit_child_nodes(node, search_in_nodes, analyzed);
diff --git a/test/parser/inline_in_test.rb b/test/parser/inline_in_test.rb
new file mode 100644
index 000000000..baccad436
--- /dev/null
+++ b/test/parser/inline_in_test.rb
@@ -0,0 +1,85 @@
+# frozen_string_literal: true
+
+require_relative "../test_helper"
+
+module Parser
+ class InlineInTest < Minitest::Spec
+ include SnapshotUtils
+
+ test "one-line pattern match against regexp as if condition" do
+ assert_parsed_snapshot(<<~HTML)
+ <% if attribute in /...+/ %>
+ <%= attribute %>
+ <% end %>
+ HTML
+ end
+
+ test "one-line pattern match as if/else condition" do
+ assert_parsed_snapshot(<<~HTML)
+ <% if 1 in Numeric %>
+
Text1
+ <% else %>
+
Text2
+ <% end %>
+ HTML
+ end
+
+ test "one-line pattern match as unless condition" do
+ assert_parsed_snapshot(<<~HTML)
+ <% unless value in [Integer] %>
+ <%= value %>
+ <% end %>
+ HTML
+ end
+
+ test "one-line pattern match as output expression" do
+ assert_parsed_snapshot(<<~HTML)
+ <%= value in [Integer] %>
+ HTML
+ end
+
+ test "one-line pattern match as elsif condition" do
+ assert_parsed_snapshot(<<~HTML)
+ <% if value in Integer %>
+
Integer
+ <% elsif value in String %>
+
String
+ <% else %>
+
Other
+ <% end %>
+ HTML
+ end
+
+ test "one-line pattern match as while condition" do
+ assert_parsed_snapshot(<<~HTML)
+ <% while value in Integer %>
+ <%= value %>
+ <% end %>
+ HTML
+ end
+
+ test "one-line pattern match as until condition" do
+ assert_parsed_snapshot(<<~HTML)
+ <% until value in Done %>
+ <%= value %>
+ <% end %>
+ HTML
+ end
+
+ test "one-line pattern match in ternary expression" do
+ assert_parsed_snapshot(<<~HTML)
+ <%= (value in Integer) ? "yes" : "no" %>
+ HTML
+ end
+
+ test "one-line pattern match inside a block body" do
+ assert_parsed_snapshot(<<~HTML)
+ <% items.each do |n| %>
+ <% if n in Integer %>
+ <%= n %>
+ <% end %>
+ <% end %>
+ HTML
+ end
+ end
+end
diff --git a/test/snapshots/engine/examples_compilation_test/test_0019_in_as_expression_compilation_62286870c09e87da8fa0d1f862c811fe.txt b/test/snapshots/engine/examples_compilation_test/test_0019_in_as_expression_compilation_62286870c09e87da8fa0d1f862c811fe.txt
new file mode 100644
index 000000000..ae7d78b7f
--- /dev/null
+++ b/test/snapshots/engine/examples_compilation_test/test_0019_in_as_expression_compilation_62286870c09e87da8fa0d1f862c811fe.txt
@@ -0,0 +1,13 @@
+---
+source: "Engine::ExamplesCompilationTest#test_0019_in as expression compilation"
+input: "{source: \"
+'.freeze;
+_buf.to_s
diff --git a/test/snapshots/engine/examples_compilation_test/test_0019_left_right_trim_compilation_0416edce0119986c84ba03c645b50717.txt b/test/snapshots/engine/examples_compilation_test/test_0020_left_right_trim_compilation_0416edce0119986c84ba03c645b50717.txt
similarity index 76%
rename from test/snapshots/engine/examples_compilation_test/test_0019_left_right_trim_compilation_0416edce0119986c84ba03c645b50717.txt
rename to test/snapshots/engine/examples_compilation_test/test_0020_left_right_trim_compilation_0416edce0119986c84ba03c645b50717.txt
index 8f70cb772..baa78159c 100644
--- a/test/snapshots/engine/examples_compilation_test/test_0019_left_right_trim_compilation_0416edce0119986c84ba03c645b50717.txt
+++ b/test/snapshots/engine/examples_compilation_test/test_0020_left_right_trim_compilation_0416edce0119986c84ba03c645b50717.txt
@@ -1,5 +1,5 @@
---
-source: "Engine::ExamplesCompilationTest#test_0019_left right trim compilation"
+source: "Engine::ExamplesCompilationTest#test_0020_left right trim compilation"
input: "{source: \"<%- if true -%>\\n
Content
\\n<%- end -%>\\n\", options: {escape: false}}"
---
_buf = ::String.new; if true
diff --git a/test/snapshots/engine/examples_compilation_test/test_0020_left_trim_compilation_12bf92840853103be656f8d585205a84.txt b/test/snapshots/engine/examples_compilation_test/test_0021_left_trim_compilation_12bf92840853103be656f8d585205a84.txt
similarity index 76%
rename from test/snapshots/engine/examples_compilation_test/test_0020_left_trim_compilation_12bf92840853103be656f8d585205a84.txt
rename to test/snapshots/engine/examples_compilation_test/test_0021_left_trim_compilation_12bf92840853103be656f8d585205a84.txt
index b4c952762..ecfd64e24 100644
--- a/test/snapshots/engine/examples_compilation_test/test_0020_left_trim_compilation_12bf92840853103be656f8d585205a84.txt
+++ b/test/snapshots/engine/examples_compilation_test/test_0021_left_trim_compilation_12bf92840853103be656f8d585205a84.txt
@@ -1,5 +1,5 @@
---
-source: "Engine::ExamplesCompilationTest#test_0020_left trim compilation"
+source: "Engine::ExamplesCompilationTest#test_0021_left trim compilation"
input: "{source: \"<%- if true %>\\n
Content
\\n<%- end %>\\n\", options: {escape: false}}"
---
_buf = ::String.new; if true
diff --git a/test/snapshots/engine/examples_compilation_test/test_0021_line_wrap_compilation_ba78b92bec7a4692a2043f2ba2ebe057.txt b/test/snapshots/engine/examples_compilation_test/test_0022_line_wrap_compilation_ba78b92bec7a4692a2043f2ba2ebe057.txt
similarity index 92%
rename from test/snapshots/engine/examples_compilation_test/test_0021_line_wrap_compilation_ba78b92bec7a4692a2043f2ba2ebe057.txt
rename to test/snapshots/engine/examples_compilation_test/test_0022_line_wrap_compilation_ba78b92bec7a4692a2043f2ba2ebe057.txt
index c95d9a482..5b3570d44 100644
--- a/test/snapshots/engine/examples_compilation_test/test_0021_line_wrap_compilation_ba78b92bec7a4692a2043f2ba2ebe057.txt
+++ b/test/snapshots/engine/examples_compilation_test/test_0022_line_wrap_compilation_ba78b92bec7a4692a2043f2ba2ebe057.txt
@@ -1,5 +1,5 @@
---
-source: "Engine::ExamplesCompilationTest#test_0021_line wrap compilation"
+source: "Engine::ExamplesCompilationTest#test_0022_line wrap compilation"
input: "{source: \"\\n\", options: {escape: false}}"
---
_buf = ::String.new; _buf << '
diff --git a/test/snapshots/engine/examples_compilation_test/test_0022_link_to_with_block_compilation_4ddb2a17755d3e775e3225970bc60a96.txt b/test/snapshots/engine/examples_compilation_test/test_0023_link_to_with_block_compilation_4ddb2a17755d3e775e3225970bc60a96.txt
similarity index 82%
rename from test/snapshots/engine/examples_compilation_test/test_0022_link_to_with_block_compilation_4ddb2a17755d3e775e3225970bc60a96.txt
rename to test/snapshots/engine/examples_compilation_test/test_0023_link_to_with_block_compilation_4ddb2a17755d3e775e3225970bc60a96.txt
index e8f5143cf..5a709cfe4 100644
--- a/test/snapshots/engine/examples_compilation_test/test_0022_link_to_with_block_compilation_4ddb2a17755d3e775e3225970bc60a96.txt
+++ b/test/snapshots/engine/examples_compilation_test/test_0023_link_to_with_block_compilation_4ddb2a17755d3e775e3225970bc60a96.txt
@@ -1,5 +1,5 @@
---
-source: "Engine::ExamplesCompilationTest#test_0022_link to with block compilation"
+source: "Engine::ExamplesCompilationTest#test_0023_link to with block compilation"
input: "{source: \"<%= link_to root_path do %>\\n
\\n Test\\n
\\n<% end %>\\n\", options: {escape: false}}"
---
_buf = ::String.new; _buf << (link_to root_path do; _buf << '
diff --git a/test/snapshots/engine/examples_compilation_test/test_0023_nested_if_and_blocks_compilation_aa8aed9ef61b138a28efed42f4b72251.txt b/test/snapshots/engine/examples_compilation_test/test_0024_nested_if_and_blocks_compilation_aa8aed9ef61b138a28efed42f4b72251.txt
similarity index 96%
rename from test/snapshots/engine/examples_compilation_test/test_0023_nested_if_and_blocks_compilation_aa8aed9ef61b138a28efed42f4b72251.txt
rename to test/snapshots/engine/examples_compilation_test/test_0024_nested_if_and_blocks_compilation_aa8aed9ef61b138a28efed42f4b72251.txt
index 20a647326..0d735806b 100644
--- a/test/snapshots/engine/examples_compilation_test/test_0023_nested_if_and_blocks_compilation_aa8aed9ef61b138a28efed42f4b72251.txt
+++ b/test/snapshots/engine/examples_compilation_test/test_0024_nested_if_and_blocks_compilation_aa8aed9ef61b138a28efed42f4b72251.txt
@@ -1,5 +1,5 @@
---
-source: "Engine::ExamplesCompilationTest#test_0023_nested if and blocks compilation"
+source: "Engine::ExamplesCompilationTest#test_0024_nested if and blocks compilation"
input: "{source: \"
\\n <%= tag.div class: \\\"div\\\" do %>\\n <% if Date.today.friday? %>\\n
\\n Happy\\n <% current_hour = Time.now.hour %>\\n\\n <% if current_hour < 12 %>\\n Early Friday\\n <% elsif current_hour >= 18 %>\\n Late Friday\\n <% else %>\\n Friday\\n <% end %>\\n
\\n <% elsif Date.today.saturday? %>\\n
\\n It's\\n Saturday\\n <%= \\\" - Time to relax!\\\" %>\\n
\\n <% else %>\\n
\\n Oh no, it's\\n Not Friday\\n <%= \\\" - Keep going!\\\" %>\\n