give better error messages for undefined modules and functions
This commit is contained in:
parent
0916dcc5bd
commit
ee57cda9c5
@ -224,7 +224,7 @@ impl<'a> Parser<'a> {
|
|||||||
let value = self
|
let value = self
|
||||||
.modules
|
.modules
|
||||||
.get(module)
|
.get(module)
|
||||||
.ok_or(("todo: module dne", module_span))?
|
.ok_or((format!("There is no module with the namespace \"{}\".", module), module_span))?
|
||||||
.get_var(var)?;
|
.get_var(var)?;
|
||||||
HigherIntermediateValue::Literal(value.clone())
|
HigherIntermediateValue::Literal(value.clone())
|
||||||
} else {
|
} else {
|
||||||
@ -235,9 +235,9 @@ impl<'a> Parser<'a> {
|
|||||||
let function = self
|
let function = self
|
||||||
.modules
|
.modules
|
||||||
.get(module)
|
.get(module)
|
||||||
.ok_or(("todo: module dne", module_span))?
|
.ok_or((format!("There is no module with the namespace \"{}\".", module), module_span))?
|
||||||
.get_fn(fn_name.node)
|
.get_fn(fn_name.node)
|
||||||
.ok_or(("todo: fn dne", fn_name.span))?;
|
.ok_or(("Undefined function.", fn_name.span))?;
|
||||||
|
|
||||||
if !matches!(self.toks.next(), Some(Token { kind: '(', .. })) {
|
if !matches!(self.toks.next(), Some(Token { kind: '(', .. })) {
|
||||||
todo!()
|
todo!()
|
||||||
|
15
tests/use.rs
15
tests/use.rs
@ -25,6 +25,21 @@ error!(
|
|||||||
"@use \"sass:math\" a math;",
|
"@use \"sass:math\" a math;",
|
||||||
"Error: expected \";\"."
|
"Error: expected \";\"."
|
||||||
);
|
);
|
||||||
|
error!(
|
||||||
|
unknown_module_get_variable,
|
||||||
|
"a { color: foo.$bar; }",
|
||||||
|
"Error: There is no module with the namespace \"foo\"."
|
||||||
|
);
|
||||||
|
error!(
|
||||||
|
unknown_module_get_function,
|
||||||
|
"a { color: foo.bar(); }",
|
||||||
|
"Error: There is no module with the namespace \"foo\"."
|
||||||
|
);
|
||||||
|
error!(
|
||||||
|
unknown_function,
|
||||||
|
"@use \"sass:math\";\na { color: math.bar(); }",
|
||||||
|
"Error: Undefined function."
|
||||||
|
);
|
||||||
test!(
|
test!(
|
||||||
use_as,
|
use_as,
|
||||||
"@use \"sass:math\" as foo;
|
"@use \"sass:math\" as foo;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user