From 970e2a045bb051861f65b19d8ede144b271ecd4b Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 25 Jun 2024 22:51:18 +0300 Subject: refactor(tvix/eval): rename UnexpectedArgument{,Formals} There's other places where unexpected arguments can be provided, like in builtins. Make space for that error type. Change-Id: Ic831497a3a1dd36a3a184bedadcf1374bf0ae6db Reviewed-on: https://cl.tvl.fyi/c/depot/+/11876 Reviewed-by: Connor Brewster Tested-by: BuildkiteCI --- tvix/eval/src/errors.rs | 10 +++++----- tvix/eval/src/vm/mod.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs index a5f79c235f09..1778fc3f1c3d 100644 --- a/tvix/eval/src/errors.rs +++ b/tvix/eval/src/errors.rs @@ -185,7 +185,7 @@ pub enum ErrorKind { FromTomlError(String), /// An unexpected argument was supplied to a function that takes formal parameters - UnexpectedArgument { + UnexpectedArgumentFormals { arg: NixString, formals_span: Span, }, @@ -487,7 +487,7 @@ to a missing value in the attribute set(s) included via `with`."#, write!(f, "Error converting TOML to a Nix value: {msg}") } - ErrorKind::UnexpectedArgument { arg, .. } => { + ErrorKind::UnexpectedArgumentFormals { arg, .. } => { write!(f, "Unexpected argument `{arg}` supplied to function",) } @@ -778,7 +778,7 @@ impl Error { ErrorKind::DuplicateAttrsKey { .. } => "in this attribute set", ErrorKind::InvalidAttributeName(_) => "in this attribute set", ErrorKind::RelativePathResolution(_) => "in this path literal", - ErrorKind::UnexpectedArgument { .. } => "in this function call", + ErrorKind::UnexpectedArgumentFormals { .. } => "in this function call", ErrorKind::UnexpectedContext => "in this string", // The spans for some errors don't have any more descriptive stuff @@ -853,7 +853,7 @@ impl Error { ErrorKind::ImportCompilerError { .. } => "E028", ErrorKind::IO { .. } => "E029", ErrorKind::JsonError { .. } => "E030", - ErrorKind::UnexpectedArgument { .. } => "E031", + ErrorKind::UnexpectedArgumentFormals { .. } => "E031", ErrorKind::RelativePathResolution(_) => "E032", ErrorKind::DivisionByZero => "E033", ErrorKind::FromTomlError(_) => "E035", @@ -898,7 +898,7 @@ impl Error { spans_for_parse_errors(&file, errors) } - ErrorKind::UnexpectedArgument { formals_span, .. } => { + ErrorKind::UnexpectedArgumentFormals { formals_span, .. } => { vec![ SpanLabel { label: self.span_label(), diff --git a/tvix/eval/src/vm/mod.rs b/tvix/eval/src/vm/mod.rs index 1fa9eba4bc5f..48dcdfc8df47 100644 --- a/tvix/eval/src/vm/mod.rs +++ b/tvix/eval/src/vm/mod.rs @@ -797,7 +797,7 @@ where if !formals.contains(arg) { return frame.error( self, - ErrorKind::UnexpectedArgument { + ErrorKind::UnexpectedArgumentFormals { arg: arg.clone(), formals_span: formals.span, }, -- cgit 1.4.1