Skip to content
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

Add some units #288

Merged
merged 1 commit into from
Jan 2, 2024
Merged

Add some units #288

merged 1 commit into from
Jan 2, 2024

Conversation

triallax
Copy link
Contributor

@triallax triallax commented Jan 2, 2024

No description provided.

@name("Rack unit")
@url("https://en.wikipedia.org/wiki/Rack_unit")
@aliases(rackunits, RU: short, U: short)
unit rackunit: Length = 0.04445 meter
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to use 1.75 inch, but this causes cargo run --example=inspect to fail (even when I have use si::imperial):

    Finished dev [unoptimized + debuginfo] target(s) in 0.27s
     Running `target/debug/examples/inspect`
thread 'main' panicked at numbat/examples/inspect.rs:11:66:
called `Result::unwrap()` on an `Err` value: TypeCheckError(UnknownIdentifier(Span { start: SourceCodePositition { byte: 3266, line: 117, position: 30 }, end: SourceCodePositition { byte: 3270, line: 117, position: 34 }, code_source_id: 16 }, "inch", None))
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: core::result::Result<T,E>::unwrap
             at /builddir/rust-1.74.0/library/core/src/result.rs:1077:23
   4: inspect::main
             at ./numbat/examples/inspect.rs:11:19
   5: core::ops::function::FnOnce::call_once
             at /builddir/rust-1.74.0/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe there's a problem with a circular dependency: imperial.nbt depends on misc.nbt, so adding a dependency from misc.nbt back to imperial might cause a problem?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe there's a problem with a circular dependency

That's it. We currently 'tolerate' cyclic dependencies:

#[test]
fn resolved_cyclic_imports() {
let program = "
use cycle_a
";
let importer = TestImporter {};
let mut resolver = Resolver::new(importer);
let program_inlined = resolver.resolve(program, CodeSource::Internal).unwrap();
assert_eq!(&program_inlined, &[]);
}

But we should probably show an error instead.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this PR, let's go with what you have, @mhmdanas. Another option would be to split this module into multiple pieces. But we can do this in a follow-up.

Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@sharkdp sharkdp merged commit 4efd0ea into master Jan 2, 2024
14 checks passed
@sharkdp sharkdp deleted the add-units branch January 2, 2024 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants