Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ mod utils;

pub mod compilation;
pub mod resolution;
pub mod semantic;
pub mod structure;
pub mod syntax;
pub mod type_system;

use compilation::CompilationDiagnosticKind;
use resolution::ResolutionDiagnosticKind;
use semantic::SemanticDiagnosticKind;
use serde::Serialize;
use structure::StructureDiagnosticKind;
use syntax::SyntaxDiagnosticKind;
Expand All @@ -33,5 +35,7 @@ define_diagnostic_kind! {
Resolution(ResolutionDiagnosticKind),
/// A diagnostic about the type system.
TypeSystem(TypeSystemDiagnosticKind),
/// A diagnostic about a semantic constraint.
Semantic(SemanticDiagnosticKind),
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use serde::Serialize;

use crate::diagnostics::extensions::DiagnosticExtensions;
use crate::diagnostics::severity::DiagnosticSeverity;

/// Diagnostic emitted when a contract's or interface's inheritance hierarchy
/// contains a cycle.
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct CyclicInheritance;

impl DiagnosticExtensions for CyclicInheritance {
fn severity(&self) -> DiagnosticSeverity {
DiagnosticSeverity::Error
}

fn code(&self) -> &'static str {
"semantic/cyclic-inheritance"
}

fn message(&self) -> String {
"Circular inheritance is not allowed.".to_owned()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use serde::Serialize;

use crate::diagnostics::extensions::DiagnosticExtensions;
use crate::diagnostics::severity::DiagnosticSeverity;

/// Diagnostic emitted when the C3 linearisation of a contract's or interface's
/// inheritance hierarchy cannot be computed.
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct LinearisationImpossible;

impl DiagnosticExtensions for LinearisationImpossible {
fn severity(&self) -> DiagnosticSeverity {
DiagnosticSeverity::Error
}

fn code(&self) -> &'static str {
"semantic/linearisation-impossible"
}

fn message(&self) -> String {
"Linearization of inheritance graph impossible.".to_owned()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
mod cyclic_inheritance;
mod linearisation_impossible;

pub use cyclic_inheritance::CyclicInheritance;
pub use linearisation_impossible::LinearisationImpossible;
use serde::Serialize;

use crate::diagnostics::kinds::utils::define_diagnostic_kind;
use crate::diagnostics::kinds::DiagnosticKind;

define_diagnostic_kind! {
parent_kind = DiagnosticKind::Semantic;

/// Group of diagnostics about semantic constraints.
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub enum SemanticDiagnosticKind {
/// A contract's or interface's inheritance hierarchy contains a cycle.
CyclicInheritance(CyclicInheritance),
/// The inheritance hierarchy cannot be linearised into a consistent
/// method resolution order.
LinearisationImpossible(LinearisationImpossible),
}
}
Loading