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

Global const set loses type #1605

Closed
Mohan-Dhawan opened this issue Dec 1, 2023 · 0 comments · Fixed by #1606
Closed

Global const set loses type #1605

Mohan-Dhawan opened this issue Dec 1, 2023 · 0 comments · Fixed by #1606
Assignees
Labels
Bug Something isn't working Compiler

Comments

@Mohan-Dhawan
Copy link

The below example fails to compile.

module Test;

import spicy;

const bar: set<string> = set("foo");

function is_bar(x: string): bool {
	if ( x in bar )
		return True;
	return False;
}

public type PDU = unit {
	: bytes &eod;

	on %done {
		print is_bar("foo");
	}	
};

The error displayed is

$ spicyc -o test.hlto -j test.spicy 
internal error: unexpected type, want hilti::type::Set but have hilti::type::Auto

--- Aborting
# [0x7ff133d75768] hilti::rt::Backtrace::Backtrace()
# [0x7ff1333e0114] hilti::util::abort_with_backtrace()
# [0x7ff133861438] 
# [0x7ff1338759a4] 
# [0x7ff13387bcca] 
# [0x7ff13387d52f] 
# [0x7ff13387fe75] hilti::detail::ast::coerce(hilti::Node*, hilti::Unit*)
# [0x7ff1338156dd] 
# [0x7ff133815fca] hilti::Unit::resolveAST(hilti::Plugin const&)
# [0x7ff133765561] hilti::Driver::_resolveUnitsWithPlugin(hilti::Plugin const&, std::vector<std::shared_ptr<hilti::Unit>, std::allocator<std::shared_ptr<hilti::Unit> > >, int&)
# [0x7ff133766e2d] hilti::Driver::_resolveUnits()
# [0x7ff1337673bc] hilti::Driver::compileUnits()
# [0x7ff133767a0c] hilti::Driver::compile()
# [0x7ff133768083] hilti::Driver::run()
# [0x557d6660ab3c] main
# [0x7ff1324280d0] 
# [0x7ff132428189] __libc_start_main
# [0x557d6660bec5] _start
Aborted (core dumped)

Changing const to global ensures successful compilation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Compiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants