mirror of
https://github.com/AleoHQ/leo.git
synced 2024-09-21 12:07:56 +03:00
prohibit external record creation
This commit is contained in:
parent
b7bd4060ec
commit
d4aed52344
@ -437,12 +437,17 @@ impl ParserContext<'_> {
|
||||
// Parse function name.
|
||||
let name = self.expect_identifier()?;
|
||||
|
||||
// Parsing a '{' means that user is trying to illegally define an external record.
|
||||
if self.token.token == Token::LeftCurly {
|
||||
return Err(ParserError::cannot_define_external_record(expr.span() + name.span()).into());
|
||||
}
|
||||
|
||||
// Parse the function call.
|
||||
let (arguments, _, span) = self.parse_paren_comma_list(|p| p.parse_expression().map(Some))?;
|
||||
|
||||
// Parse the parent program identifier.
|
||||
let program: Option<ProgramId> = match expr {
|
||||
Expression::Identifier(identifier) => Some(ProgramId::from(identifier)),
|
||||
let program: Option<Symbol> = match expr {
|
||||
Expression::Identifier(identifier) => Some(identifier.name),
|
||||
_ => unreachable!("Function called must be preceded by a program identifier."),
|
||||
};
|
||||
|
||||
|
@ -335,4 +335,11 @@ create_messages!(
|
||||
msg: format!("Only external calls to `.aleo` programs are supported."),
|
||||
help: None,
|
||||
}
|
||||
|
||||
@formatted
|
||||
cannot_define_external_record {
|
||||
args: (),
|
||||
msg: format!("Cannot create an external record. Records can only be created from scratch in the program that they are defined in."),
|
||||
help: None,
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user