mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
Using abilities as types is illegal, but we can still compile them
Closes #2881
This commit is contained in:
parent
c0dec1d5bc
commit
80dc50763e
7 changed files with 151 additions and 4 deletions
|
@ -188,3 +188,31 @@ fn ability_constrained_in_non_member_multiple_specializations_inferred() {
|
|||
u64
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn ability_used_as_type_still_compiles() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [ result ] to "./platform"
|
||||
|
||||
Hash has
|
||||
hash : a -> U64 | a has Hash
|
||||
|
||||
mulHashes : Hash, Hash -> U64
|
||||
mulHashes = \x, y -> hash x * hash y
|
||||
|
||||
Id := U64
|
||||
hash = \$Id n -> n
|
||||
|
||||
Three := {}
|
||||
hash = \$Three _ -> 3
|
||||
|
||||
result = mulHashes ($Id 100) ($Three {})
|
||||
"#
|
||||
),
|
||||
300,
|
||||
u64
|
||||
)
|
||||
}
|
||||
|
|
|
@ -106,8 +106,9 @@ fn create_llvm_module<'a>(
|
|||
|
||||
use roc_problem::can::Problem::*;
|
||||
for problem in can_problems.into_iter() {
|
||||
// Ignore "unused" problems
|
||||
dbg!(&problem);
|
||||
match problem {
|
||||
// Ignore "unused" problems
|
||||
UnusedDef(_, _)
|
||||
| UnusedArgument(_, _, _)
|
||||
| UnusedImport(_, _)
|
||||
|
@ -122,6 +123,8 @@ fn create_llvm_module<'a>(
|
|||
delayed_errors.push(buf.clone());
|
||||
lines.push(buf);
|
||||
}
|
||||
// We should be able to compile even when abilities are used as types
|
||||
AbilityUsedAsType(..) => {}
|
||||
_ => {
|
||||
let report = can_problem(&alloc, &line_info, module_path.clone(), problem);
|
||||
let mut buf = String::new();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue