From ebc97438e70e54855f507b09ba90ae878c5f534e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 18 Dec 2017 16:24:31 -0800 Subject: [PATCH] Add a test that two mutable borrows is not ok --- tests/classes.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/classes.rs b/tests/classes.rs index ead8cbc6..b52359c5 100644 --- a/tests/classes.rs +++ b/tests/classes.rs @@ -124,6 +124,12 @@ fn exceptions() { pub fn new() -> A { A {} } + + pub fn foo(&self, _: &A) { + } + + pub fn bar(&mut self, _: &mut A) { + } } } "#) @@ -136,6 +142,14 @@ fn exceptions() { a.free(); // TODO: figure out a better error message? assert.throws(() => a.free(), /RuntimeError: unreachable/); + + let b = wasm.A.new(); + try { + b.foo(b); + assert.throws(() => b.bar(b), /RuntimeError: unreachable/); + } finally { + b.free(); + } } "#) .test();