Skip to content

Commit

Permalink
add failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlicanC committed Oct 11, 2022
1 parent dc7a60f commit 58624f9
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sway-error/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,8 @@ pub enum CompileError {
ConfigTimeConstantNotALiteral { span: Span },
#[error("ref mut parameter not allowed for main()")]
RefMutableNotAllowedInMain { param_name: Ident },
#[error("returning raw_ptrs are not allowed for main()")]
PointerReturnNotAllowedInMain { span: Span },
}

impl std::convert::From<TypeError> for CompileError {
Expand Down Expand Up @@ -828,6 +830,7 @@ impl Spanned for CompileError {
ConfigTimeConstantNotAConstDecl { span } => span.clone(),
ConfigTimeConstantNotALiteral { span } => span.clone(),
RefMutableNotAllowedInMain { param_name } => param_name.span(),
PointerReturnNotAllowedInMain { span } => span.clone(),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[[package]]
name = 'core'
source = 'path+from-root-51D3AF48CE04FAE0'
dependencies = []

[[package]]
name = 'raw_ptr_ret'
source = 'root'
dependencies = ['std']

[[package]]
name = 'std'
source = 'path+from-root-51D3AF48CE04FAE0'
dependencies = ['core']
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[project]
authors = ["Fuel Labs <contact@fuel.sh>"]
entry = "main.sw"
license = "Apache-2.0"
name = "raw_ptr_ret"

[dependencies]
std = { path = "../../../../../../../sway-lib-std" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
script;

fn main() -> raw_ptr {
let ptr = asm(r1) { r1: raw_ptr };
ptr
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
category = "fail"

# check: fn main() -> raw_ptr {
# nextln: $()returning raw_ptrs are not allowed for main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[[package]]
name = 'core'
source = 'path+from-root-D3556C503E51030C'
dependencies = []

[[package]]
name = 'std'
source = 'path+from-root-D3556C503E51030C'
dependencies = ['core']

[[package]]
name = 'vec_ret'
source = 'root'
dependencies = ['std']
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[project]
authors = ["Fuel Labs <contact@fuel.sh>"]
entry = "main.sw"
license = "Apache-2.0"
name = "vec_ret"

[dependencies]
std = { path = "../../../../../../../sway-lib-std" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
script;

use std::vec::Vec;

fn main() -> Vec<u64> {
let vec = ~Vec::new();
vec
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
category = "fail"

# check: fn main() -> Vec<u64> {
# nextln: $()returning raw_ptrs are not allowed for main()

0 comments on commit 58624f9

Please sign in to comment.