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

ICE - return outside function #2477

Closed
MahadMuhammad opened this issue Jul 28, 2023 · 0 comments · Fixed by #2486
Closed

ICE - return outside function #2477

MahadMuhammad opened this issue Jul 28, 2023 · 0 comments · Fixed by #2486
Assignees
Labels

Comments

@MahadMuhammad
Copy link
Contributor

E0572 - return statement was found outside of a function body:


I tried this code from E0572

const FOO: u32 = return 0; // error: return statement outside of function body

fn main() {}

Meta

  • What version of Rust GCC were you using, git sha 1bc8f08
  • gccrs (Compiler-Explorer-Build-gcc-ccac7ed46c2e81434714d74a86d58d2e5e1df7c8-binutils-2.40) 13.0.1 20230417 (experimental)

Error output

  • Internal Compiler Error:
Backtrace :

crab1: internal compiler error: in peek_return_type, at rust/typecheck/rust-typecheck-context.cc:148
0x7bb5ac Rust::Resolver::TypeCheckContext::peek_return_type()
	../../gccrs/gcc/rust/typecheck/rust-typecheck-context.cc:148
0xc20e92 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::ReturnExpr&)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-expr.cc:153
0xc1fce3 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr*)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-expr.cc:41
0xc0cf70 Rust::Resolver::TypeCheckItem::visit(Rust::HIR::ConstantItem&)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:313
0xc0d500 Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:49
0xc0d500 Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:35
0xbd3b5b Rust::Resolver::TypeResolution::Resolve(Rust::HIR::Crate&)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check.cc:37
0xa712bb Rust::Session::compile_crate(char const*)
	../../gccrs/gcc/rust/rust-session-manager.cc:631
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

@philberty philberty self-assigned this Jul 29, 2023
philberty added a commit that referenced this issue Jul 29, 2023
Fixes #2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
github-merge-queue bot pushed a commit that referenced this issue Jul 30, 2023
Fixes #2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
@github-project-automation github-project-automation bot moved this from Todo to Done in libcore 1.49 Jul 30, 2023
@MahadMuhammad MahadMuhammad moved this from Internal Compile Error to Done Supported Error Codes in Error Code Support & Improving User Errors Aug 9, 2023
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Nov 15, 2023
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Nov 21, 2023
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Nov 21, 2023
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 5, 2024
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 8, 2024
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 11, 2024
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 12, 2024
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 16, 2024
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 16, 2024
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Jan 17, 2024
Fixes Rust-GCC#2477

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	We need to check if a function context exists

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2477.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants