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

Panic when duplicating field in record destructuring #1318

Closed
matthew-healy opened this issue May 24, 2023 · 0 comments · Fixed by #1324
Closed

Panic when duplicating field in record destructuring #1318

matthew-healy opened this issue May 24, 2023 · 0 comments · Fixed by #1324

Comments

@matthew-healy
Copy link
Contributor

matthew-healy commented May 24, 2023

Describe the bug

The following program:

let f : { x : Number, y : Number } -> Number = fun { x, x, .. } => x in f { x = 1, y = 2 }

panics with the following error message:

thread 'main' panicked at 'Scopes of identifiers in destruct patterns should be checked already', src/typecheck/destructuring.rs:247:14

Expected behavior

Ideally a parser error noting that record destructurings cannot contain duplicate fields, but just not panicking is a good first step.

Additional context

Full backtrace
thread 'main' panicked at 'Scopes of identifiers in destruct patterns should be checked already', src/typecheck/destructuring.rs:247:14
stack backtrace:
   0:     0x5568a92baf4a - std::backtrace_rs::backtrace::libunwind::trace::h595f06c70adcc478
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x5568a92baf4a - std::backtrace_rs::backtrace::trace_unsynchronized::h177a0149c76cdde9
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x5568a92baf4a - std::sys_common::backtrace::_print_fmt::hc0701fd2c3530c58
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x5568a92baf4a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd4cd115d8750fd6c
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x5568a92e06de - core::fmt::write::h93e2f5923c7eca08
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/fmt/mod.rs:1213:17
   5:     0x5568a92b7ce5 - std::io::Write::write_fmt::h8162dbb45f0b9e62
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/io/mod.rs:1682:15
   6:     0x5568a92bad15 - std::sys_common::backtrace::_print::h1835ef8a8f9066da
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x5568a92bad15 - std::sys_common::backtrace::print::hcb5e6388b9235f41
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x5568a92bc39f - std::panicking::default_hook::{{closure}}::h9c084969ccf9a722
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:267:22
   9:     0x5568a92bc0db - std::panicking::default_hook::h68fa2ba3c3c6c12f
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:286:9
  10:     0x5568a92bcaa9 - std::panicking::rust_panic_with_hook::h8d5c434518ef298c
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:688:13
  11:     0x5568a92bc849 - std::panicking::begin_panic_handler::{{closure}}::hf33414f5dabf6faf
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:579:13
  12:     0x5568a92bb3fc - std::sys_common::backtrace::__rust_end_short_backtrace::hc50389427413bb75
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:137:18
  13:     0x5568a92bc552 - rust_begin_unwind
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:575:5
  14:     0x5568a84b1d73 - core::panicking::panic_fmt::h2de7a7938f816de8
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/panicking.rs:64:14
  15:     0x5568a92de721 - core::panicking::panic_display::h20dbb78c57df5693
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/panicking.rs:147:5
  16:     0x5568a92de6cb - core::panicking::panic_str::hb46d5710e4ab412a
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/panicking.rs:131:5
  17:     0x5568a84b1d36 - core::option::expect_failed::h0b5d04c30548770b
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/option.rs:1924:5
  18:     0x5568a8a3bc99 - core::option::Option<T>::expect::h6d8c9ee88dc7065d
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/option.rs:786:21
  19:     0x5568a88a1654 - nickel_lang::typecheck::destructuring::RecordTypes::get_type::h93ee428ae91dbc08
                               at /home/matthew/projects/tweag/nickel/src/typecheck/destructuring.rs:245:9
  20:     0x5568a8552003 - nickel_lang::typecheck::destructuring::inject_pattern_variables::{{closure}}::hdcbcb524b0fe83f2
                               at /home/matthew/projects/tweag/nickel/src/typecheck/destructuring.rs:150:22
  21:     0x5568a850da44 - <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::for_each::h09b6b4f4c7e2be3a
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/slice/iter/macros.rs:201:21
  22:     0x5568a88a10fb - nickel_lang::typecheck::destructuring::inject_pattern_variables::hb489469de17ee90b
                               at /home/matthew/projects/tweag/nickel/src/typecheck/destructuring.rs:148:5
  23:     0x5568a8718c12 - nickel_lang::typecheck::check::h38230333c6737771
                               at /home/matthew/projects/tweag/nickel/src/typecheck/mod.rs:1231:13
  24:     0x5568a8711d0c - nickel_lang::typecheck::walk_with_annot::hfccd3a73a9a3ad20
                               at /home/matthew/projects/tweag/nickel/src/typecheck/mod.rs:1103:13
  25:     0x5568a8711817 - nickel_lang::typecheck::walk_annotated::hbd6d76235fca61f7
                               at /home/matthew/projects/tweag/nickel/src/typecheck/mod.rs:1076:5
  26:     0x5568a870eaf1 - nickel_lang::typecheck::walk::hb432fd114ee9f501
                               at /home/matthew/projects/tweag/nickel/src/typecheck/mod.rs:989:13
  27:     0x5568a870ff6a - nickel_lang::typecheck::walk::hb432fd114ee9f501
                               at /home/matthew/projects/tweag/nickel/src/typecheck/mod.rs:904:13
  28:     0x5568a870dea7 - nickel_lang::typecheck::type_check_linearize::h3257ed68140ce287
                               at /home/matthew/projects/tweag/nickel/src/typecheck/mod.rs:797:9
  29:     0x5568a870dab2 - nickel_lang::typecheck::type_check::h32824a8e4d2c9d65
                               at /home/matthew/projects/tweag/nickel/src/typecheck/mod.rs:760:5
  30:     0x5568a8733c61 - nickel_lang::repl::ReplImpl<EC>::prepare::hf894c25bed851a71
                               at /home/matthew/projects/tweag/nickel/src/repl/mod.rs:120:13
  31:     0x5568a8734b3d - nickel_lang::repl::ReplImpl<EC>::eval_::hc7728a17ab7aa4e4
                               at /home/matthew/projects/tweag/nickel/src/repl/mod.rs:181:25
  32:     0x5568a8735317 - <nickel_lang::repl::ReplImpl<EC> as nickel_lang::repl::Repl>::eval_full::h1114207f84015fb5
                               at /home/matthew/projects/tweag/nickel/src/repl/mod.rs:200:9
  33:     0x5568a88bfd88 - nickel_lang::repl::rustyline_frontend::repl::hc8040fe009c478b2
                               at /home/matthew/projects/tweag/nickel/src/repl/rustyline_frontend.rs:122:23
  34:     0x5568a84d6f29 - nickel::main::haa397c64b8c52d44
                               at /home/matthew/projects/tweag/nickel/src/bin/nickel.rs:147:12
  35:     0x5568a84eb83b - core::ops::function::FnOnce::call_once::h8e2db0c97b9470e0
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/ops/function.rs:250:5
  36:     0x5568a84f8dee - std::sys_common::backtrace::__rust_begin_short_backtrace::h99e3a67a48b8bf1b
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:121:18
  37:     0x5568a84ca771 - std::rt::lang_start::{{closure}}::h40c3e8d2cd41369c
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/rt.rs:166:18
  38:     0x5568a92b155c - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h699977d052768608
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/ops/function.rs:287:13
  39:     0x5568a92b155c - std::panicking::try::do_call::h4e121e623c70f903
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:483:40
  40:     0x5568a92b155c - std::panicking::try::hf9d919e062bc178a
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:447:19
  41:     0x5568a92b155c - std::panic::catch_unwind::h7a7b12272684cb97
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panic.rs:140:14
  42:     0x5568a92b155c - std::rt::lang_start_internal::{{closure}}::hd96b0eb4844b8762
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/rt.rs:148:48
  43:     0x5568a92b155c - std::panicking::try::do_call::h1af1f88f4f92a22c
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:483:40
  44:     0x5568a92b155c - std::panicking::try::hf20d7abea7f0f097
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:447:19
  45:     0x5568a92b155c - std::panic::catch_unwind::hb0e084c3a9c042e4
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panic.rs:140:14
  46:     0x5568a92b155c - std::rt::lang_start_internal::hca9d5c7277f5b67c
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/rt.rs:148:20
  47:     0x5568a84ca74a - std::rt::lang_start::h5c2fdacb750165c9
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/rt.rs:165:17
  48:     0x5568a84de4ce - main
  49:     0x7f36afa2924e - __libc_start_call_main
  50:     0x7f36afa29309 - __libc_start_main_alias_1
  51:     0x5568a84b2405 - _start
  52:                0x0 - <unknown>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant