-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove different behaviour when single input #1902
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -371,7 +371,7 @@ impl<EC: EvalCache> Program<EC> { | |
pub fn parse(&mut self) -> Result<RichTerm, Error> { | ||
self.vm | ||
.import_resolver_mut() | ||
.parse(self.main_id) | ||
.parse(self.main_id, InputFormat::Nickel) | ||
.map_err(Error::ParseErrors)?; | ||
Ok(self | ||
.vm | ||
|
@@ -496,7 +496,9 @@ impl<EC: EvalCache> Program<EC> { | |
|
||
/// Load, parse, and typecheck the program and the standard library, if not already done. | ||
pub fn typecheck(&mut self) -> Result<(), Error> { | ||
self.vm.import_resolver_mut().parse(self.main_id)?; | ||
self.vm | ||
.import_resolver_mut() | ||
.parse(self.main_id, InputFormat::Nickel)?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, I think any |
||
self.vm.import_resolver_mut().load_stdlib()?; | ||
let initial_env = self.vm.import_resolver().mk_type_ctxt().expect( | ||
"program::typecheck(): \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,7 +171,7 @@ macro_rules! ncl_bench_group { | |
(name = $group_name:ident; config = $config:expr; $($b:tt),+ $(,)*) => { | ||
pub fn $group_name() { | ||
use nickel_lang_core::{ | ||
cache::{Envs, Cache, ErrorTolerance, ImportResolver}, | ||
cache::{Envs, Cache, ErrorTolerance, ImportResolver, InputFormat}, | ||
eval::{VirtualMachine, cache::{CacheImpl, Cache as EvalCache}}, | ||
transform::import_resolution::strict::resolve_imports, | ||
error::report::{report, ColorOpt, ErrorFormat}, | ||
|
@@ -194,7 +194,7 @@ macro_rules! ncl_bench_group { | |
.unwrap() | ||
.transformed_term; | ||
if bench.eval_mode == $crate::bench::EvalMode::TypeCheck { | ||
cache.parse(id).unwrap(); | ||
cache.parse(id, InputFormat::Nickel).unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you should either:
But in any case, the consumers/callers of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Edit: I meant should NOT have to import it themselves. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, right now I see. I missed that the code I edited was inside a macro, sure it's a mistake. So, I'll import it in macro, and get rid of those imports from benches:) |
||
cache.resolve_imports(id).unwrap(); | ||
} | ||
(cache, id, t) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if those shouldn't guess the format as well, instead of
InputFormat::Nickel
. That's why it could be handy to have aparse_auto
(the name isn't great, so feel free to use another if you find some!). However, this one can also be done in a subsequent PR, as the current code at least fixes the original issue.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parse_infer_format
? less concise, but more descriptive ...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olorin37 right, it's a reasonable suggestion and better than
parse_auto
, so go for it 🙂