Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spec/test] Fix scoping of non-imported globals #1525

Merged
merged 4 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions interpreter/valid/valid.ml
Original file line number Diff line number Diff line change
Expand Up @@ -726,10 +726,10 @@ let check_module (m : module_) =
in
List.iter check_type types;
List.iter (check_global c1) globals;
List.iter (check_table c1) tables;
List.iter (check_memory c1) memories;
List.iter (check_elem c1) elems;
List.iter (check_data c1) datas;
List.iter (check_table c) tables;
List.iter (check_memory c) memories;
List.iter (check_elem c) elems;
List.iter (check_data c) datas;
List.iter (check_func c) funcs;
Lib.Option.app (check_start c) start;
ignore (List.fold_left (check_export c) NameSet.empty exports);
Expand Down
15 changes: 7 additions & 8 deletions test/core/data.wast
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
(data (global.get $g) "a")
)

;; Use of internal globals in constant expressions is not allowed in MVP.
;; (module (memory 1) (data (global.get 0) "a") (global i32 (i32.const 0)))
;; (module (memory 1) (data (global.get $g) "a") (global $g i32 (i32.const 0)))
(module (memory 1) (data (global.get 0) "a") (global i32 (i32.const 0)))
(module (memory 1) (data (global.get $g) "a") (global $g i32 (i32.const 0)))


;; Corner cases

Expand Down Expand Up @@ -456,11 +456,10 @@
"constant expression required"
)

;; Use of internal globals in constant expressions is not allowed in MVP.
;; (assert_invalid
;; (module (memory 1) (data (global.get $g)) (global $g (mut i32) (i32.const 0)))
;; "constant expression required"
;; )
(assert_invalid
(module (memory 1) (data (global.get $g)) (global $g (mut i32) (i32.const 0)))
"constant expression required"
)

(assert_invalid
(module
Expand Down
13 changes: 8 additions & 5 deletions test/core/elem.wast
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@
(assert_return (invoke "call-7") (i32.const 65))
(assert_return (invoke "call-9") (i32.const 66))

(module (table 1 funcref) (elem (global.get 0) $f) (global i32 (i32.const 0)) (func $f))
(module (table 1 funcref) (elem (global.get $g) $f) (global $g i32 (i32.const 0)) (func $f))


;; Corner cases

(module
Expand Down Expand Up @@ -425,11 +429,10 @@
"constant expression required"
)

;; Use of internal globals in constant expressions is not allowed in MVP.
;; (assert_invalid
;; (module (table 1 funcref) (elem (global.get $g)) (global $g i32 (i32.const 0)))
;; "constant expression required"
;; )
(assert_invalid
(module (table 1 funcref) (elem (global.get $g)) (global $g (mut i32) (i32.const 0)))
"constant expression required"
)

(assert_invalid
(module
Expand Down