Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
edg-l committed May 10, 2024
2 parents 0cf2f53 + 56a8221 commit 0d134dd
Show file tree
Hide file tree
Showing 29 changed files with 646 additions and 107 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,25 @@ jobs:
run: sudo apt-get install libc-dev build-essential
- name: test
run: make test

test-macos:
name: test (macOS)
runs-on: macos-14
env:
CARGO_TERM_COLOR: always
LIBRARY_PATH: /opt/homebrew/lib
MLIR_SYS_180_PREFIX: /opt/homebrew/opt/llvm@18
LLVM_SYS_180_PREFIX: /opt/homebrew/opt/llvm@18
TABLEGEN_180_PREFIX: /opt/homebrew/opt/llvm@18
RUST_LOG: debug
steps:
- uses: actions/checkout@v4
- name: Rustup toolchain install
uses: dtolnay/rust-toolchain@1.78.0
- uses: homebrew/actions/setup-homebrew@master
- name: install llvm
run: brew install llvm@18
- name: Run tests
run: make test
coverage:
name: coverage
runs-on: ubuntu-latest
Expand Down
7 changes: 7 additions & 0 deletions crates/concrete_ast/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ pub struct GenericParam {
pub params: Vec<TypeSpec>,
pub span: Span,
}

#[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
pub struct Attribute {
pub name: String,
pub value: Option<String>,
pub span: Span,
}
3 changes: 2 additions & 1 deletion crates/concrete_ast/src/functions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
common::{DocString, GenericParam, Ident, Span},
common::{Attribute, DocString, GenericParam, Ident, Span},
statements::Statement,
types::TypeSpec,
};
Expand All @@ -13,6 +13,7 @@ pub struct FunctionDecl {
pub ret_type: Option<TypeSpec>,
pub is_extern: bool,
pub is_pub: bool,
pub attributes: Vec<Attribute>,
pub span: Span,
}

Expand Down
90 changes: 78 additions & 12 deletions crates/concrete_check/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn lowering_error_to_report(
program_id,
} => {
let offset = span.from;
let path = session.file_paths[program_id].to_str().unwrap().to_string();
let path = session.file_paths[program_id].display().to_string();
Report::build(ReportKind::Error, path.clone(), offset)
.with_code("ModuleNotFound")
.with_label(
Expand All @@ -34,7 +34,7 @@ pub fn lowering_error_to_report(
function,
program_id,
} => {
let path = session.file_paths[program_id].to_str().unwrap().to_string();
let path = session.file_paths[program_id].display().to_string();
Report::build(ReportKind::Error, path.clone(), span.from)
.with_code("FunctionNotFound")
.with_label(
Expand All @@ -49,7 +49,7 @@ pub fn lowering_error_to_report(
name,
program_id,
} => {
let path = session.file_paths[program_id].to_str().unwrap().to_string();
let path = session.file_paths[program_id].display().to_string();
Report::build(ReportKind::Error, path.clone(), span.from)
.with_code("StructFieldNotFound")
.with_label(
Expand All @@ -65,7 +65,7 @@ pub fn lowering_error_to_report(
symbol,
program_id,
} => {
let path = session.file_paths[program_id].to_str().unwrap().to_string();
let path = session.file_paths[program_id].display().to_string();
let offset = symbol.span.from;
Report::build(ReportKind::Error, path.clone(), offset)
.with_code("ImportNotFound")
Expand All @@ -91,7 +91,7 @@ pub fn lowering_error_to_report(
type_span,
program_id,
} => {
let path = session.file_paths[program_id].to_str().unwrap().to_string();
let path = session.file_paths[program_id].display().to_string();
let mut labels = vec![Label::new((path.clone(), span.into()))
.with_message(format!(
"Can't mutate {name:?} because it's behind a immutable borrow"
Expand All @@ -116,7 +116,7 @@ pub fn lowering_error_to_report(
name,
program_id,
} => {
let path = session.file_paths[program_id].to_str().unwrap().to_string();
let path = session.file_paths[program_id].display().to_string();
Report::build(ReportKind::Error, path.clone(), span.from)
.with_code("UnrecognizedType")
.with_label(
Expand All @@ -132,7 +132,7 @@ pub fn lowering_error_to_report(
id,
program_id,
} => {
let path = session.file_paths[program_id].to_str().unwrap().to_string();
let path = session.file_paths[program_id].display().to_string();
Report::build(ReportKind::Error, path.clone(), span.from)
.with_code("E_ID")
.with_label(
Expand All @@ -148,7 +148,7 @@ pub fn lowering_error_to_report(
message,
program_id,
} => {
let path = session.file_paths[program_id].to_str().unwrap().to_string();
let path = session.file_paths[program_id].display().to_string();
Report::build(ReportKind::Error, path.clone(), span.from)
.with_code("NotYetImplemented")
.with_label(
Expand All @@ -164,7 +164,7 @@ pub fn lowering_error_to_report(
expected,
program_id,
} => {
let path = session.file_paths[program_id].to_str().unwrap().to_string();
let path = session.file_paths[program_id].display().to_string();
let mut labels = vec![Label::new((path.clone(), span.into()))
.with_message(format!(
"Unexpected type '{}', expected '{}'",
Expand All @@ -191,7 +191,7 @@ pub fn lowering_error_to_report(
name,
program_id,
} => {
let path = session.file_paths[program_id].to_str().unwrap().to_string();
let path = session.file_paths[program_id].display().to_string();
Report::build(ReportKind::Error, path.clone(), span.from)
.with_code("UseOfUndeclaredVariable")
.with_label(
Expand All @@ -206,7 +206,7 @@ pub fn lowering_error_to_report(
name,
program_id,
} => {
let path = session.file_paths[program_id].to_str().unwrap().to_string();
let path = session.file_paths[program_id].display().to_string();
Report::build(ReportKind::Error, path.clone(), span.from)
.with_code("ExternFnWithBody")
.with_label(
Expand All @@ -217,11 +217,77 @@ pub fn lowering_error_to_report(
.finish()
}
LoweringError::InternalError(msg, program_id) => {
let path = session.file_paths[program_id].to_str().unwrap().to_string();
let path = session.file_paths[program_id].display().to_string();
Report::build(ReportKind::Error, path.clone(), 0)
.with_code("InternalError")
.with_message(msg)
.finish()
}
LoweringError::CallParamCountMismatch {
span,
found,
needs,
program_id,
} => {
let path = session.file_paths[program_id].display().to_string();
Report::build(ReportKind::Error, path.clone(), span.from)
.with_code("CallParamCountMismatch")
.with_label(
Label::new((path, span.into()))
.with_message(format!(
"function call parameter count mismatch: found {}, needs {}.",
found, needs
))
.with_color(colors.next()),
)
.finish()
}

LoweringError::NotMutable {
span,
declare_span,
program_id,
} => {
let path = session.file_paths[program_id].display().to_string();
let mut report = Report::build(ReportKind::Error, path.clone(), span.from)
.with_code("NotMutable")
.with_label(
Label::new((path.clone(), span.into()))
.with_message("can't mutate this variable because it's not mutable")
.with_color(colors.next()),
);

if let Some(declare_span) = declare_span {
report = report.with_label(
Label::new((path, declare_span.into()))
.with_message("variable declared here")
.with_color(colors.next()),
);
}
report.finish()
}
LoweringError::CantTakeMutableBorrow {
span,
declare_span,
program_id,
} => {
let path = session.file_paths[program_id].display().to_string();
let mut report = Report::build(ReportKind::Error, path.clone(), span.from)
.with_code("CantTakeMutableBorrow")
.with_label(
Label::new((path.clone(), span.into()))
.with_message("can't take a mutate borrow to this variable because it's not declared mutable")
.with_color(colors.next()),
);

if let Some(declare_span) = declare_span {
report = report.with_label(
Label::new((path, declare_span.into()))
.with_message("variable declared here")
.with_color(colors.next()),
);
}
report.finish()
}
}
}
16 changes: 0 additions & 16 deletions crates/concrete_codegen_mlir/build.rs

This file was deleted.

Loading

0 comments on commit 0d134dd

Please sign in to comment.