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

better error message for doc comment without an item #4970

Merged
merged 2 commits into from
Aug 18, 2023
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
2 changes: 2 additions & 0 deletions sway-error/src/parser_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ pub enum ParseErrorKind {
ExpectedImportNameGroupOrGlob,
#[error("Expected an item.")]
ExpectedAnItem,
#[error("Expected item after doc comment.")]
xunilrj marked this conversation as resolved.
Show resolved Hide resolved
ExpectedAnItemAfterDocComment,
#[error("Expected a comma or closing parenthesis in function arguments.")]
ExpectedCommaOrCloseParenInFnArgs,
#[error("Unrecognized op code.")]
Expand Down
17 changes: 11 additions & 6 deletions sway-parse/src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,18 @@ impl<T: Parse> Parse for Annotated<T> {
attribute_list.push(attr);
}

// Parse the `T` value.
let value = parser.parse()?;
if parser.check_empty().is_some() {
let error = parser.emit_error(ParseErrorKind::ExpectedAnItemAfterDocComment);
Err(error)
} else {
// Parse the `T` value.
let value = parser.parse()?;

Ok(Annotated {
attribute_list,
value,
})
Ok(Annotated {
attribute_list,
value,
})
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[package]]
name = 'addrof_intrinsic'
source = 'member'
dependencies = ['std']

[[package]]
name = 'core'
source = 'path+from-root-B3EAB3022B5FAD04'

[[package]]
name = 'std'
source = 'path+from-root-B3EAB3022B5FAD04'
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 = "addrof_intrinsic"

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

use std::{constants::ZERO_B256, vm::evm::evm_address::EvmAddress};

configurable {
/// SIGNER: EvmAddress = EvmAddress {
/// value: ZERO_B256,
/// }
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
category = "fail"

# check: $()Expected item after doc comment