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

Fixes crash on encode_buffer_append with wrong args. #6365

Merged
merged 3 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,14 @@ fn type_check_encode_append(
_type_arguments: &[TypeArgument],
span: Span,
) -> Result<(ty::TyIntrinsicFunctionKind, TypeId), ErrorEmitted> {
if arguments.len() != 2 {
return Err(handler.emit_err(CompileError::IntrinsicIncorrectNumArgs {
name: kind.to_string(),
expected: 2,
span,
}));
}

let type_engine = ctx.engines.te();
let engines = ctx.engines();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[[package]]
name = "encode_append_wrong_args"
source = "member"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[project]
authors = ["Fuel Labs <contact@fuel.sh>"]
entry = "main.sw"
license = "Apache-2.0"
name = "encode_append_wrong_args"
implicit-std = false
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
library;

pub struct Buffer {
buffer: u64
}

pub trait T {
fn ar(buffer: Buffer) -> Buffer;
}

impl T for str[10] {
fn ar(buffer: Buffer) -> Buffer {
Buffer {
buffer: __encode_buffer_append(buffer.buffer)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
category = "fail"

# check: $()warning
# check: $()buffer: __encode_buffer_append(buffer.buffer)

# check: $()buffer: __encode_buffer_append(buffer.buffer)
# nextln: $()Call to "encode_buffer_append" expects 2 arguments
Loading