Skip to content

Commit cc42201

Browse files
committed
move type checking from lib.rs into compile.rs
Now the only use of ConstructNode, and incomplete types more broadly, occurs within compile.rs. This will make it much easier for us to update rust-simplicity to require scoped type inference contexts.
1 parent 901cf91 commit cc42201

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/compile.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::ast::{
1414
};
1515
use crate::debug::CallTracker;
1616
use crate::error::{Error, RichError, Span, WithSpan};
17-
use crate::named::{CoreExt, PairBuilder};
17+
use crate::named::{self, CoreExt, PairBuilder};
1818
use crate::num::{NonZeroPow2Usize, Pow2Usize};
1919
use crate::pattern::{BasePattern, Pattern};
2020
use crate::str::WitnessName;
@@ -257,13 +257,18 @@ impl Program {
257257
&self,
258258
arguments: Arguments,
259259
include_debug_symbols: bool,
260-
) -> Result<ProgNode, RichError> {
260+
) -> Result<Arc<named::CommitNode>, RichError> {
261261
let mut scope = Scope::new(
262262
Arc::clone(self.call_tracker()),
263263
arguments,
264264
include_debug_symbols,
265265
);
266-
self.main().compile(&mut scope).map(PairBuilder::build)
266+
267+
let main = self.main();
268+
let construct = main.compile(&mut scope).map(PairBuilder::build)?;
269+
// SimplicityHL types should be correct by construction. If not, assign the
270+
// whole main function as the span for them, which is as sensible as anything.
271+
named::finalize_types(&construct).with_span(&main)
267272
}
268273
}
269274

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,10 @@ impl TemplateProgram {
8181
.is_consistent(self.simfony.parameters())
8282
.map_err(|error| error.to_string())?;
8383

84-
let construct = self
84+
let commit = self
8585
.simfony
8686
.compile(arguments, include_debug_symbols)
8787
.with_file(Arc::clone(&self.file))?;
88-
let commit = named::finalize_types(&construct).map_err(|e| e.to_string())?;
8988

9089
Ok(CompiledProgram {
9190
debug_symbols: self.simfony.debug_symbols(self.file.as_ref()),

0 commit comments

Comments
 (0)