parent
61a991cb23
commit
976262c2e6
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
- **aiken-lang**: duplicate import lines are now automatically merged instead of raising a warning. However, imports can no longer appear anywhere in the file and must come as the first definitions. @KtorZ
|
- **aiken-lang**: duplicate import lines are now automatically merged instead of raising a warning. However, imports can no longer appear anywhere in the file and must come as the first definitions. @KtorZ
|
||||||
|
|
||||||
|
- **aiken-lang**: remove warning on discarded expect, allowing to keep 'side-effects' when necessary. See #967. @KtorZ
|
||||||
|
|
||||||
## v1.0.29-alpha - 2024-06-06
|
## v1.0.29-alpha - 2024-06-06
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{Definition, ModuleKind, TraceLevel, Tracing, TypedModule, UntypedModule},
|
ast::{Definition, ModuleKind, Pattern, TraceLevel, Tracing, TypedModule, UntypedModule},
|
||||||
builtins,
|
builtins,
|
||||||
expr::TypedExpr,
|
expr::TypedExpr,
|
||||||
parser,
|
parser,
|
||||||
|
@ -2720,3 +2720,44 @@ fn if_soft_cast_not_data() {
|
||||||
|
|
||||||
assert!(matches!(warnings[0], Warning::UseWhenInstead { .. }))
|
assert!(matches!(warnings[0], Warning::UseWhenInstead { .. }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn side_effects() {
|
||||||
|
let source_code = r#"
|
||||||
|
pub fn side_effects() {
|
||||||
|
trace "Aiken, rocks!"
|
||||||
|
Void
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn foo() {
|
||||||
|
expect _ = side_effects()
|
||||||
|
True
|
||||||
|
}
|
||||||
|
"#;
|
||||||
|
|
||||||
|
let (warnings, ast) = check(parse(source_code)).unwrap();
|
||||||
|
|
||||||
|
assert!(warnings.is_empty(), "no warnings: {warnings:#?}");
|
||||||
|
|
||||||
|
if let Some(Definition::Fn(ref foo)) = ast.definitions().last() {
|
||||||
|
if let TypedExpr::Sequence {
|
||||||
|
ref expressions, ..
|
||||||
|
} = foo.body
|
||||||
|
{
|
||||||
|
matches!(
|
||||||
|
expressions[..],
|
||||||
|
[
|
||||||
|
TypedExpr::Assignment {
|
||||||
|
pattern: Pattern::Discard { .. },
|
||||||
|
..
|
||||||
|
},
|
||||||
|
TypedExpr::Var { .. },
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1251,7 +1251,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
.check_exhaustiveness(&[&pattern], location, false)
|
.check_exhaustiveness(&[&pattern], location, false)
|
||||||
.is_ok();
|
.is_ok();
|
||||||
|
|
||||||
if !value_is_data && is_exaustive_pattern {
|
if !value_is_data && is_exaustive_pattern && !pattern.is_discard() {
|
||||||
self.environment
|
self.environment
|
||||||
.warnings
|
.warnings
|
||||||
.push(Warning::SingleConstructorExpect {
|
.push(Warning::SingleConstructorExpect {
|
||||||
|
|
Loading…
Reference in New Issue