mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
Move constrain and its deps into their own crates
This commit is contained in:
parent
758de2e7bf
commit
908e485fca
58 changed files with 633 additions and 422 deletions
61
compiler/problem/src/can.rs
Normal file
61
compiler/problem/src/can.rs
Normal file
|
@ -0,0 +1,61 @@
|
|||
use inlinable_string::InlinableString;
|
||||
use roc_module::ident::Ident;
|
||||
use roc_module::symbol::{ModuleId, Symbol};
|
||||
use roc_parse::operator::BinOp;
|
||||
use roc_parse::pattern::PatternType;
|
||||
use roc_region::all::{Located, Region};
|
||||
|
||||
/// Problems that can occur in the course of canonicalization.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum Problem {
|
||||
UnusedDef(Symbol, Region),
|
||||
UnusedImport(ModuleId, Region),
|
||||
UnusedArgument(Symbol, Region),
|
||||
PrecedenceProblem(PrecedenceProblem),
|
||||
// Example: (5 = 1 + 2) is an unsupported pattern in an assignment; Int patterns aren't allowed in assignments!
|
||||
UnsupportedPattern(PatternType, Region),
|
||||
ShadowingInAnnotation {
|
||||
original_region: Region,
|
||||
shadow: Located<Ident>,
|
||||
},
|
||||
RuntimeError(RuntimeError),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum PrecedenceProblem {
|
||||
BothNonAssociative(Located<BinOp>, Located<BinOp>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum RuntimeError {
|
||||
Shadowing {
|
||||
original_region: Region,
|
||||
shadow: Located<Ident>,
|
||||
},
|
||||
UnrecognizedFunctionName(Located<InlinableString>),
|
||||
LookupNotInScope(Located<InlinableString>),
|
||||
ValueNotExposed {
|
||||
module_name: InlinableString,
|
||||
ident: InlinableString,
|
||||
region: Region,
|
||||
},
|
||||
ModuleNotImported {
|
||||
module_name: InlinableString,
|
||||
ident: InlinableString,
|
||||
region: Region,
|
||||
},
|
||||
InvalidPrecedence(PrecedenceProblem, Region),
|
||||
FloatOutsideRange(Box<str>),
|
||||
IntOutsideRange(Box<str>),
|
||||
InvalidHex(std::num::ParseIntError, Box<str>),
|
||||
InvalidOctal(std::num::ParseIntError, Box<str>),
|
||||
InvalidBinary(std::num::ParseIntError, Box<str>),
|
||||
QualifiedPatternIdent(InlinableString),
|
||||
CircularDef(
|
||||
Vec<Located<Ident>>,
|
||||
Vec<(Region /* pattern */, Region /* expr */)>,
|
||||
),
|
||||
|
||||
/// When the author specifies a type annotation but no implementation
|
||||
NoImplementation,
|
||||
}
|
13
compiler/problem/src/lib.rs
Normal file
13
compiler/problem/src/lib.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
#![warn(clippy::all, clippy::dbg_macro)]
|
||||
// I'm skeptical that clippy:large_enum_variant is a good lint to have globally enabled.
|
||||
//
|
||||
// It warns about a performance problem where the only quick remediation is
|
||||
// to allocate more on the heap, which has lots of tradeoffs - including making it
|
||||
// long-term unclear which allocations *need* to happen for compilation's sake
|
||||
// (e.g. recursive structures) versus those which were only added to appease clippy.
|
||||
//
|
||||
// Effectively optimizing data struture memory layout isn't a quick fix,
|
||||
// and encouraging shortcuts here creates bad incentives. I would rather temporarily
|
||||
// re-enable this when working on performance optimizations than have it block PRs.
|
||||
#![allow(clippy::large_enum_variant)]
|
||||
pub mod can;
|
Loading…
Add table
Add a link
Reference in a new issue