From e4cf10e49106255e06ce402e20e2302eb8e8bbd5 Mon Sep 17 00:00:00 2001
From: Mingun <alexander_sergey@mail.ru>
Date: Fri, 27 Sep 2024 00:47:17 +0500
Subject: [PATCH 1/5] Update error messages changed in
 https://github.com/kaitai-io/kaitai_struct_compiler/pull/309

---
 formats_err/enum_unknown_inst_value.ksy                | 2 +-
 formats_err/enum_unknown_seq.ksy                       | 2 +-
 formats_err/expr_cast_type_unknown.ksy                 | 2 +-
 formats_err/expr_enum_unknown.ksy                      | 2 +-
 formats_err/expr_field_unknown_endian_switch_cases.ksy | 2 +-
 formats_err/expr_field_unknown_endian_switch_on.ksy    | 2 +-
 formats_err/expr_field_unknown_if_inst_pos.ksy         | 2 +-
 formats_err/expr_field_unknown_if_inst_value.ksy       | 2 +-
 formats_err/expr_field_unknown_if_seq.ksy              | 2 +-
 formats_err/expr_field_unknown_inst_value_enum.ksy     | 2 +-
 formats_err/expr_field_unknown_params_call.ksy         | 2 +-
 formats_err/expr_field_unknown_switch_cases.ksy        | 2 +-
 formats_err/expr_field_unknown_switch_on.ksy           | 2 +-
 formats_err/expr_field_unknown_switch_params_call.ksy  | 2 +-
 formats_err/expr_field_unknown_valid_any_of.ksy        | 4 ++--
 formats_err/expr_field_unknown_valid_eq_long.ksy       | 2 +-
 formats_err/expr_field_unknown_valid_eq_short.ksy      | 2 +-
 formats_err/expr_field_unknown_valid_expr.ksy          | 2 +-
 formats_err/expr_field_unknown_valid_range.ksy         | 4 ++--
 formats_err/params_def_type_unknown.ksy                | 2 +-
 formats_err/type_unknown.ksy                           | 2 +-
 formats_err/type_unknown_many.ksy                      | 6 +++---
 formats_err/type_unknown_switch.ksy                    | 2 +-
 23 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/formats_err/enum_unknown_inst_value.ksy b/formats_err/enum_unknown_inst_value.ksy
index 4e1fb1e83..cbc0a94f6 100644
--- a/formats_err/enum_unknown_inst_value.ksy
+++ b/formats_err/enum_unknown_inst_value.ksy
@@ -1,5 +1,5 @@
 # enum_unknown_inst_value.ksy: /instances/should_fail/enum:
-# 	error: unable to find enum 'animal', searching from enum_unknown_inst_value
+# 	error: unable to find enum 'animal', searching from 'enum_unknown_inst_value'
 #
 meta:
   id: enum_unknown_inst_value
diff --git a/formats_err/enum_unknown_seq.ksy b/formats_err/enum_unknown_seq.ksy
index e443f5b7c..5e4c86755 100644
--- a/formats_err/enum_unknown_seq.ksy
+++ b/formats_err/enum_unknown_seq.ksy
@@ -1,5 +1,5 @@
 # enum_unknown_seq.ksy: /seq/0/enum:
-# 	error: unable to find enum 'animal', searching from enum_unknown_seq
+# 	error: unable to find enum 'animal', searching from 'enum_unknown_seq'
 #
 meta:
   id: enum_unknown_seq
diff --git a/formats_err/expr_cast_type_unknown.ksy b/formats_err/expr_cast_type_unknown.ksy
index 9963795cb..ff0afff57 100644
--- a/formats_err/expr_cast_type_unknown.ksy
+++ b/formats_err/expr_cast_type_unknown.ksy
@@ -1,5 +1,5 @@
 # expr_cast_type_unknown.ksy: /instances/foo_bar/value:
-# 	error: unable to find type 'bar', searching from expr_cast_type_unknown
+# 	error: unable to find type 'bar', searching from 'expr_cast_type_unknown'
 #
 meta:
   id: expr_cast_type_unknown
diff --git a/formats_err/expr_enum_unknown.ksy b/formats_err/expr_enum_unknown.ksy
index db3e02045..bf57eccec 100644
--- a/formats_err/expr_enum_unknown.ksy
+++ b/formats_err/expr_enum_unknown.ksy
@@ -1,5 +1,5 @@
 # expr_enum_unknown.ksy: /seq/1/if:
-# 	error: unable to find enum 'unknown_enum', searching from expr_enum_unknown
+# 	error: unable to find enum 'unknown_enum', searching from 'expr_enum_unknown'
 #
 meta:
   id: expr_enum_unknown
diff --git a/formats_err/expr_field_unknown_endian_switch_cases.ksy b/formats_err/expr_field_unknown_endian_switch_cases.ksy
index 66d809193..7d17b076e 100644
--- a/formats_err/expr_field_unknown_endian_switch_cases.ksy
+++ b/formats_err/expr_field_unknown_endian_switch_cases.ksy
@@ -1,5 +1,5 @@
 # expr_field_unknown_endian_switch_cases.ksy: /meta/endian/cases/Name(identifier(qux)):
-# 	error: unable to access 'qux' in expr_field_unknown_endian_switch_cases context
+# 	error: unable to access 'qux' in 'expr_field_unknown_endian_switch_cases' context
 #
 meta:
   id: expr_field_unknown_endian_switch_cases
diff --git a/formats_err/expr_field_unknown_endian_switch_on.ksy b/formats_err/expr_field_unknown_endian_switch_on.ksy
index 555d5eb85..0455aa085 100644
--- a/formats_err/expr_field_unknown_endian_switch_on.ksy
+++ b/formats_err/expr_field_unknown_endian_switch_on.ksy
@@ -1,5 +1,5 @@
 # expr_field_unknown_endian_switch_on.ksy: /meta/endian/switch-on:
-# 	error: unable to access 'qux' in expr_field_unknown_endian_switch_on context
+# 	error: unable to access 'qux' in 'expr_field_unknown_endian_switch_on' context
 #
 meta:
   id: expr_field_unknown_endian_switch_on
diff --git a/formats_err/expr_field_unknown_if_inst_pos.ksy b/formats_err/expr_field_unknown_if_inst_pos.ksy
index 3c59851d5..3dfabe33f 100644
--- a/formats_err/expr_field_unknown_if_inst_pos.ksy
+++ b/formats_err/expr_field_unknown_if_inst_pos.ksy
@@ -1,5 +1,5 @@
 # expr_field_unknown_if_inst_pos.ksy: /instances/foo/if:
-# 	error: unable to access 'bar' in expr_field_unknown_if_inst_pos context
+# 	error: unable to access 'bar' in 'expr_field_unknown_if_inst_pos' context
 #
 meta:
   id: expr_field_unknown_if_inst_pos
diff --git a/formats_err/expr_field_unknown_if_inst_value.ksy b/formats_err/expr_field_unknown_if_inst_value.ksy
index 761f2f152..b8b6208a0 100644
--- a/formats_err/expr_field_unknown_if_inst_value.ksy
+++ b/formats_err/expr_field_unknown_if_inst_value.ksy
@@ -1,5 +1,5 @@
 # expr_field_unknown_if_inst_value.ksy: /instances/foo/if:
-# 	error: unable to access 'bar' in expr_field_unknown_if_inst_value context
+# 	error: unable to access 'bar' in 'expr_field_unknown_if_inst_value' context
 #
 meta:
   id: expr_field_unknown_if_inst_value
diff --git a/formats_err/expr_field_unknown_if_seq.ksy b/formats_err/expr_field_unknown_if_seq.ksy
index c4b5ef03e..5bd85aa68 100644
--- a/formats_err/expr_field_unknown_if_seq.ksy
+++ b/formats_err/expr_field_unknown_if_seq.ksy
@@ -1,5 +1,5 @@
 # expr_field_unknown_if_seq.ksy: /seq/0/if:
-# 	error: unable to access 'bar' in expr_field_unknown_if_seq context
+# 	error: unable to access 'bar' in 'expr_field_unknown_if_seq' context
 #
 meta:
   id: expr_field_unknown_if_seq
diff --git a/formats_err/expr_field_unknown_inst_value_enum.ksy b/formats_err/expr_field_unknown_inst_value_enum.ksy
index 6023a0234..28ed69a82 100644
--- a/formats_err/expr_field_unknown_inst_value_enum.ksy
+++ b/formats_err/expr_field_unknown_inst_value_enum.ksy
@@ -1,5 +1,5 @@
 # expr_field_unknown_inst_value_enum.ksy: /instances/foo/value:
-# 	error: unable to access 'bar' in expr_field_unknown_inst_value_enum context
+# 	error: unable to access 'bar' in 'expr_field_unknown_inst_value_enum' context
 #
 meta:
   id: expr_field_unknown_inst_value_enum
diff --git a/formats_err/expr_field_unknown_params_call.ksy b/formats_err/expr_field_unknown_params_call.ksy
index 1086c4ae8..18336d34d 100644
--- a/formats_err/expr_field_unknown_params_call.ksy
+++ b/formats_err/expr_field_unknown_params_call.ksy
@@ -1,5 +1,5 @@
 # expr_field_unknown_params_call.ksy: /seq/0/type:
-# 	error: unable to access 'bar' in expr_field_unknown_params_call context
+# 	error: unable to access 'bar' in 'expr_field_unknown_params_call' context
 #
 meta:
   id: expr_field_unknown_params_call
diff --git a/formats_err/expr_field_unknown_switch_cases.ksy b/formats_err/expr_field_unknown_switch_cases.ksy
index b85888820..d61f56880 100644
--- a/formats_err/expr_field_unknown_switch_cases.ksy
+++ b/formats_err/expr_field_unknown_switch_cases.ksy
@@ -1,5 +1,5 @@
 # expr_field_unknown_switch_cases.ksy: /seq/1/type/cases/Name(identifier(ahem)):
-# 	error: unable to access 'ahem' in expr_field_unknown_switch_cases context
+# 	error: unable to access 'ahem' in 'expr_field_unknown_switch_cases' context
 #
 meta:
   id: expr_field_unknown_switch_cases
diff --git a/formats_err/expr_field_unknown_switch_on.ksy b/formats_err/expr_field_unknown_switch_on.ksy
index 6fd504c84..dd6d7ec2e 100644
--- a/formats_err/expr_field_unknown_switch_on.ksy
+++ b/formats_err/expr_field_unknown_switch_on.ksy
@@ -1,5 +1,5 @@
 # expr_field_unknown_switch_on.ksy: /seq/0/type/switch-on:
-# 	error: unable to access 'bar' in expr_field_unknown_switch_on context
+# 	error: unable to access 'bar' in 'expr_field_unknown_switch_on' context
 #
 meta:
   id: expr_field_unknown_switch_on
diff --git a/formats_err/expr_field_unknown_switch_params_call.ksy b/formats_err/expr_field_unknown_switch_params_call.ksy
index e0b29e078..c88bec27c 100644
--- a/formats_err/expr_field_unknown_switch_params_call.ksy
+++ b/formats_err/expr_field_unknown_switch_params_call.ksy
@@ -1,5 +1,5 @@
 # expr_field_unknown_switch_params_call.ksy: /seq/0/type/cases/Bool(true):
-# 	error: unable to access 'bar' in expr_field_unknown_switch_params_call context
+# 	error: unable to access 'bar' in 'expr_field_unknown_switch_params_call' context
 #
 meta:
   id: expr_field_unknown_switch_params_call
diff --git a/formats_err/expr_field_unknown_valid_any_of.ksy b/formats_err/expr_field_unknown_valid_any_of.ksy
index 846d4e031..2a77ef622 100644
--- a/formats_err/expr_field_unknown_valid_any_of.ksy
+++ b/formats_err/expr_field_unknown_valid_any_of.ksy
@@ -1,8 +1,8 @@
 # expr_field_unknown_valid_any_of.ksy: /seq/0/valid/any-of/1:
-# 	error: unable to access 'bar' in expr_field_unknown_valid_any_of context
+# 	error: unable to access 'bar' in 'expr_field_unknown_valid_any_of' context
 #
 # expr_field_unknown_valid_any_of.ksy: /seq/0/valid/any-of/3:
-# 	error: unable to access 'qux' in expr_field_unknown_valid_any_of context
+# 	error: unable to access 'qux' in 'expr_field_unknown_valid_any_of' context
 #
 meta:
   id: expr_field_unknown_valid_any_of
diff --git a/formats_err/expr_field_unknown_valid_eq_long.ksy b/formats_err/expr_field_unknown_valid_eq_long.ksy
index 2a131e0e2..84da5a533 100644
--- a/formats_err/expr_field_unknown_valid_eq_long.ksy
+++ b/formats_err/expr_field_unknown_valid_eq_long.ksy
@@ -1,5 +1,5 @@
 # expr_field_unknown_valid_eq_long.ksy: /seq/0/valid/eq:
-# 	error: unable to access 'bar' in expr_field_unknown_valid_eq_long context
+# 	error: unable to access 'bar' in 'expr_field_unknown_valid_eq_long' context
 #
 meta:
   id: expr_field_unknown_valid_eq_long
diff --git a/formats_err/expr_field_unknown_valid_eq_short.ksy b/formats_err/expr_field_unknown_valid_eq_short.ksy
index ae6e183ee..b4394ec52 100644
--- a/formats_err/expr_field_unknown_valid_eq_short.ksy
+++ b/formats_err/expr_field_unknown_valid_eq_short.ksy
@@ -1,5 +1,5 @@
 # expr_field_unknown_valid_eq_short.ksy: /seq/0/valid:
-# 	error: unable to access 'bar' in expr_field_unknown_valid_eq_short context
+# 	error: unable to access 'bar' in 'expr_field_unknown_valid_eq_short' context
 #
 meta:
   id: expr_field_unknown_valid_eq_short
diff --git a/formats_err/expr_field_unknown_valid_expr.ksy b/formats_err/expr_field_unknown_valid_expr.ksy
index 96f0ff89f..44dc54ef3 100644
--- a/formats_err/expr_field_unknown_valid_expr.ksy
+++ b/formats_err/expr_field_unknown_valid_expr.ksy
@@ -1,5 +1,5 @@
 # expr_field_unknown_valid_expr.ksy: /seq/0/valid/expr:
-# 	error: unable to access 'bar' in expr_field_unknown_valid_expr context
+# 	error: unable to access 'bar' in 'expr_field_unknown_valid_expr' context
 #
 meta:
   id: expr_field_unknown_valid_expr
diff --git a/formats_err/expr_field_unknown_valid_range.ksy b/formats_err/expr_field_unknown_valid_range.ksy
index 6e8a258a4..cfedcc3a0 100644
--- a/formats_err/expr_field_unknown_valid_range.ksy
+++ b/formats_err/expr_field_unknown_valid_range.ksy
@@ -1,8 +1,8 @@
 # expr_field_unknown_valid_range.ksy: /seq/0/valid/min:
-# 	error: unable to access 'bar' in expr_field_unknown_valid_range context
+# 	error: unable to access 'bar' in 'expr_field_unknown_valid_range' context
 #
 # expr_field_unknown_valid_range.ksy: /seq/0/valid/max:
-# 	error: unable to access 'qux' in expr_field_unknown_valid_range context
+# 	error: unable to access 'qux' in 'expr_field_unknown_valid_range' context
 #
 meta:
   id: expr_field_unknown_valid_range
diff --git a/formats_err/params_def_type_unknown.ksy b/formats_err/params_def_type_unknown.ksy
index 7597bd786..5f963cdf1 100644
--- a/formats_err/params_def_type_unknown.ksy
+++ b/formats_err/params_def_type_unknown.ksy
@@ -1,5 +1,5 @@
 # params_def_type_unknown.ksy: /params/0/type:
-# 	error: unable to find type 'bar', searching from params_def_type_unknown
+# 	error: unable to find type 'bar', searching from 'params_def_type_unknown'
 #
 meta:
   id: params_def_type_unknown
diff --git a/formats_err/type_unknown.ksy b/formats_err/type_unknown.ksy
index 6e29cbed8..27748c113 100644
--- a/formats_err/type_unknown.ksy
+++ b/formats_err/type_unknown.ksy
@@ -1,5 +1,5 @@
 # type_unknown.ksy: /seq/0/type:
-# 	error: unable to find type 'some_unknown_name', searching from type_unknown
+# 	error: unable to find type 'some_unknown_name', searching from 'type_unknown'
 #
 meta:
   id: type_unknown
diff --git a/formats_err/type_unknown_many.ksy b/formats_err/type_unknown_many.ksy
index 0cdce035b..5bac50467 100644
--- a/formats_err/type_unknown_many.ksy
+++ b/formats_err/type_unknown_many.ksy
@@ -1,11 +1,11 @@
 # type_unknown_many.ksy: /seq/0/type:
-# 	error: unable to find type 'some_unknown_name', searching from type_unknown_many
+# 	error: unable to find type 'some_unknown_name', searching from 'type_unknown_many'
 #
 # type_unknown_many.ksy: /seq/1/type:
-# 	error: unable to find type 'also_unknown_name', searching from type_unknown_many
+# 	error: unable to find type 'also_unknown_name', searching from 'type_unknown_many'
 #
 # type_unknown_many.ksy: /seq/2/enum:
-# 	error: unable to find enum 'unknown_enum', searching from type_unknown_many
+# 	error: unable to find enum 'unknown_enum', searching from 'type_unknown_many'
 #
 meta:
   id: type_unknown_many
diff --git a/formats_err/type_unknown_switch.ksy b/formats_err/type_unknown_switch.ksy
index 879be41ac..201c3fae6 100644
--- a/formats_err/type_unknown_switch.ksy
+++ b/formats_err/type_unknown_switch.ksy
@@ -1,5 +1,5 @@
 # type_unknown_switch.ksy: /seq/0/type/cases/IntNum(42):
-# 	error: unable to find type 'some_unknown_name', searching from type_unknown_switch
+# 	error: unable to find type 'some_unknown_name', searching from 'type_unknown_switch'
 #
 meta:
   id: type_unknown_switch

From b76684676fddb3e9646989d3c3af8c890bb71216 Mon Sep 17 00:00:00 2001
From: Mingun <alexander_sergey@mail.ru>
Date: Fri, 27 Sep 2024 00:52:47 +0500
Subject: [PATCH 2/5] Add tests for checking unknown types and enums in array
 elements

I saw earlier that there probably was problems with processing of array types,
when such errors inside them not reported. Add tests to ensure that they are being checked
---
 formats_err/type_unknown_many.ksy | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/formats_err/type_unknown_many.ksy b/formats_err/type_unknown_many.ksy
index 5bac50467..236b2703a 100644
--- a/formats_err/type_unknown_many.ksy
+++ b/formats_err/type_unknown_many.ksy
@@ -7,6 +7,12 @@
 # type_unknown_many.ksy: /seq/2/enum:
 # 	error: unable to find enum 'unknown_enum', searching from 'type_unknown_many'
 #
+# type_unknown_many.ksy: /seq/3/type:
+# 	error: unable to find type 'unknown_type_in_array', searching from 'type_unknown_many'
+#
+# type_unknown_many.ksy: /seq/4/enum:
+# 	error: unable to find enum 'unknown_enum_in_array', searching from 'type_unknown_many'
+#
 meta:
   id: type_unknown_many
   ks-opaque-types: false
@@ -18,3 +24,10 @@ seq:
   - id: baz
     type: u1
     enum: unknown_enum
+  - id: type_in_array
+    type: unknown_type_in_array
+    repeat: eos
+  - id: enum_in_array
+    type: u1
+    enum: unknown_enum_in_array
+    repeat: eos

From 64a345b96a3d26b9551618a04a4f31802eeee187 Mon Sep 17 00:00:00 2001
From: Mingun <Alexander_Sergey@mail.ru>
Date: Sun, 6 Oct 2024 02:31:09 +0500
Subject: [PATCH 3/5] Fix error messages for
 https://github.com/kaitai-io/kaitai_struct_compiler/pull/310

---
 formats_err/expr_compare_enum2.ksy | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/formats_err/expr_compare_enum2.ksy b/formats_err/expr_compare_enum2.ksy
index 10f37f19e..15788c7e6 100644
--- a/formats_err/expr_compare_enum2.ksy
+++ b/formats_err/expr_compare_enum2.ksy
@@ -1,5 +1,5 @@
 # expr_compare_enum2.ksy: /seq/1/if:
-# 	error: can't compare EnumType(List(animal),Int1Type(false)) and Int1Type(true)
+# 	error: can't compare EnumType(EnumRef(false,List(),animal),Int1Type(false)) and Int1Type(true)
 #
 meta:
   id: expr_compare_enum2

From 7611f157813930cec56ecfe3bc7edbee01208831 Mon Sep 17 00:00:00 2001
From: Mingun <alexander_sergey@mail.ru>
Date: Wed, 17 Apr 2024 21:01:57 +0500
Subject: [PATCH 4/5] formats_err: add test for leaking types

Tests for https://github.com/kaitai-io/kaitai_struct/issues/534

Adds new failing test in compiler:

[info] - imports_type_leaking *** FAILED ***
[info]   []
[info]     did not equal
[info]   [imports/type_two.ksy: /seq/0/type:
[info]          error: unable to find type 'type_one', searching from 'type_two'
[info]   ] (SimpleMatchers.scala:34)
---
 formats_err/imports/type_one.ksy     |  6 ++++++
 formats_err/imports/type_two.ksy     |  7 +++++++
 formats_err/imports_type_leaking.ksy | 13 +++++++++++++
 3 files changed, 26 insertions(+)
 create mode 100644 formats_err/imports/type_one.ksy
 create mode 100644 formats_err/imports/type_two.ksy
 create mode 100644 formats_err/imports_type_leaking.ksy

diff --git a/formats_err/imports/type_one.ksy b/formats_err/imports/type_one.ksy
new file mode 100644
index 000000000..1247d2a53
--- /dev/null
+++ b/formats_err/imports/type_one.ksy
@@ -0,0 +1,6 @@
+# This is a file that is imported in imports_type_leaking.ksy
+meta:
+  id: type_one
+seq:
+  - id: something
+    size: 4
diff --git a/formats_err/imports/type_two.ksy b/formats_err/imports/type_two.ksy
new file mode 100644
index 000000000..35f05ae0b
--- /dev/null
+++ b/formats_err/imports/type_two.ksy
@@ -0,0 +1,7 @@
+# This is a file that is imported in imports_type_leaking.ksy
+meta:
+  id: type_two
+  # Note: missing import of `type_one`
+seq:
+  - id: one
+    type: type_one # Note: `type_one` is not imported in this spec, so this should cause a compile error
diff --git a/formats_err/imports_type_leaking.ksy b/formats_err/imports_type_leaking.ksy
new file mode 100644
index 000000000..609b1331e
--- /dev/null
+++ b/formats_err/imports_type_leaking.ksy
@@ -0,0 +1,13 @@
+# imports/type_two.ksy: /seq/0/type:
+# 	error: unable to find type 'type_one', searching from 'type_two'
+#
+meta:
+  id: imports_type_leaking
+  imports:
+    - imports/type_one
+    - imports/type_two
+seq:
+  - id: another_one
+    type: type_one
+  - id: another_two
+    type: type_two

From 09ad33bf866db501d93c85a109f695c79fcb9c7e Mon Sep 17 00:00:00 2001
From: Mingun <alexander_sergey@mail.ru>
Date: Wed, 17 Apr 2024 21:28:32 +0500
Subject: [PATCH 5/5] formats_err: add test for leaking enums

Tests for https://github.com/kaitai-io/kaitai_struct/issues/534

Adds new failing test in compiler:

[info] - imports_enum_leaking *** FAILED ***
[info]   []
[info]     did not equal
[info]   [imports/enum_two.ksy: /seq/0/enum:
[info]          error: unable to find type 'enum_one', searching from 'enum_two'
[info]
[info]   imports/enum_two.ksy: /instances/instance_one/enum:
[info]          error: unable to find type 'enum_one', searching from 'enum_two'
[info]   ] (SimpleMatchers.scala:34)
---
 formats_err/imports/enum_one.ksy     | 10 ++++++++++
 formats_err/imports/enum_two.ksy     | 16 ++++++++++++++++
 formats_err/imports_enum_leaking.ksy | 25 +++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
 create mode 100644 formats_err/imports/enum_one.ksy
 create mode 100644 formats_err/imports/enum_two.ksy
 create mode 100644 formats_err/imports_enum_leaking.ksy

diff --git a/formats_err/imports/enum_one.ksy b/formats_err/imports/enum_one.ksy
new file mode 100644
index 000000000..0a3229638
--- /dev/null
+++ b/formats_err/imports/enum_one.ksy
@@ -0,0 +1,10 @@
+# This is a file that is imported in imports_enum_leaking.ksy
+meta:
+  id: enum_one
+seq:
+  - id: something
+    type: u1
+    enum: one
+enums:
+  one:
+    0: zero
diff --git a/formats_err/imports/enum_two.ksy b/formats_err/imports/enum_two.ksy
new file mode 100644
index 000000000..9fe016b84
--- /dev/null
+++ b/formats_err/imports/enum_two.ksy
@@ -0,0 +1,16 @@
+# This is a file that is imported in imports_enum_leaking.ksy
+meta:
+  id: enum_two
+  # Note: missing import of `enum_one`
+seq:
+  - id: one
+    type: u1
+    enum: enum_one::one # Note: `enum_one` is not imported in this spec, so this should cause a compile error
+instances:
+  # Enum resolution in value instances significantly different from enum resolution in other attributes
+  instance_one:
+    value: 0
+    enum: enum_one::one # Note: `enum_one` is not imported in this spec, so this should cause a compile error
+enums:
+  two:
+    0: zero
diff --git a/formats_err/imports_enum_leaking.ksy b/formats_err/imports_enum_leaking.ksy
new file mode 100644
index 000000000..8135894d4
--- /dev/null
+++ b/formats_err/imports_enum_leaking.ksy
@@ -0,0 +1,25 @@
+# imports/enum_two.ksy: /seq/0/enum:
+# 	error: unable to find type 'enum_one', searching from 'enum_two'
+#
+# imports/enum_two.ksy: /instances/instance_one/enum:
+# 	error: unable to find type 'enum_one', searching from 'enum_two'
+#
+meta:
+  id: imports_enum_leaking
+  imports:
+    - imports/enum_one
+    - imports/enum_two
+seq:
+  - id: another_one
+    type: u1
+    enum: enum_one::one
+  - id: another_two
+    type: u1
+    enum: enum_two::two
+instances:
+  instance_one:
+    value: 0
+    enum: enum_one::one
+  instance_two:
+    value: 0
+    enum: enum_two::two