fix honey compiler blockers

This commit is contained in:
2026-08-05 08:18:11 +02:00
parent 9e79d6692b
commit 84b88f6127
7 changed files with 141 additions and 39 deletions
+100 -3
View File
@@ -1738,6 +1738,16 @@ layout_builtins_compile_and_run :: proc(t: ^testing.T) {
y u8
}
Bool_First :: struct {
flag bool
byte u8
}
Bool_Last :: struct {
byte u8
flag bool
}
Opaque :: opaque
Color :: enum {
red
@@ -1755,6 +1765,20 @@ buffer func($T type) [sizeof!(T)]u8 {
return data
}
make_bool_first func() Bool_First {
value Bool_First = undefined
value.flag = true
value.byte = 41
return value
}
make_bool_last func() Bool_Last {
value Bool_Last = undefined
value.byte = 42
value.flag = true
return value
}
main func() i32 {
bytes [_]u8 :: buffer(i32)
if (needs_usize(SIZE_GLOBAL) != 4) return 1
@@ -1771,6 +1795,15 @@ main func() i32 {
if (alignof!(Point) != 4) return 12
if (sizeof!(UserID) != 4) return 13
if (alignof!(UserID) != 4) return 14
if (sizeof!(bool) != 1) return 15
if (sizeof!(Bool_First) != 2) return 16
if (sizeof!(Bool_Last) != 2) return 17
first :: make_bool_first()
if (!first.flag) return 18
if (first.byte != 41) return 19
last :: make_bool_last()
if (!last.flag) return 20
if (last.byte != 42) return 21
return 0
}
`
@@ -5560,19 +5593,27 @@ init_project_creates_missing_layout_and_preserves_existing_files :: proc(t: ^tes
}
@(test)
build_root_search_finds_nearest_parent_build_file :: proc(t: ^testing.T) {
build_hon_is_discovered_from_nested_directory_and_builds :: proc(t: ^testing.T) {
root := "/tmp/brolang-test-build-search"
nested := "/tmp/brolang-test-build-search/source/nested"
build_bro := "/tmp/brolang-test-build-search/build.bro"
build_hon := "/tmp/brolang-test-build-search/build.hon"
output := "/tmp/brolang-test-build-search/build/brolang-test-build-search"
_ = os2.remove_all(root)
defer _ = os2.remove_all(root)
testing.expect(t, init_project(root))
testing.expect(t, os.rename(build_bro, build_hon))
testing.expect(t, os2.make_directory_all(nested) == nil)
build_text := "# root\n"
testing.expect(t, os.write_entire_file("/tmp/brolang-test-build-search/build.bro", transmute([]byte)build_text))
found, ok := compiler_core.find_build_root_from(nested)
defer delete(found)
testing.expect(t, ok)
testing.expect(t, strings.has_suffix(found, "/brolang-test-build-search"))
status := compiler_core.run_build(found)
testing.expect_value(t, status, 0)
state := run_executable(output)
testing.expect_value(t, state.exit_code, 0)
}
@(test)
@@ -10460,6 +10501,62 @@ cross_package_recursive_specialization_reaches_fixed_point :: proc(t: ^testing.T
testing.expect(t, os.exists(output))
}
@(test)
qualified_concrete_call_in_runtime_for_retains_specialization :: proc(t: ^testing.T) {
directory := "/tmp/brolang-test-qualified-concrete-call"
ast_directory := "/tmp/brolang-test-qualified-concrete-call/ast"
main_path := "/tmp/brolang-test-qualified-concrete-call/main.hon"
ast_path := "/tmp/brolang-test-qualified-concrete-call/ast/ast.hon"
output := "/tmp/brolang-test-qualified-concrete-call-output"
ast_text := `Node :: struct { token usize }
Token :: struct { start usize }
render_literal func(node @Node, tokens []Token, program []u8) ?[]u8 {
if (node.token >= tokens.len) return null
token :: tokens[node.token]
if (token.start >= program.len) return null
return program[token.start..token.start+1]
}
`
main_text := `ast :: import "./ast"
main func() i32 {
nodes [1]mut ast.Node = undefined
nodes[0].token = 0
token_storage [1]mut ast.Token = undefined
token_storage[0].start = 0
mutable_tokens []mut ast.Token = token_storage[..]
program :: "x"
for nodes |node| {
_ = ast.render_literal(&node, mutable_tokens, program)
}
return 0
}
`
_ = os2.remove_all(directory)
defer _ = os2.remove_all(directory)
defer _ = os.remove(output)
testing.expect(t, os.make_directory(directory) == nil)
testing.expect(t, os.make_directory(ast_directory) == nil)
testing.expect(t, os.write_entire_file(main_path, transmute([]byte)main_text))
testing.expect(t, os.write_entire_file(ast_path, transmute([]byte)ast_text))
sources := source.init_store()
defer source.destroy_store(&sources)
diagnostics := source.init_store_diagnostics(&sources)
defer source.destroy_diagnostics(&diagnostics)
symbols := symbol.init_table()
defer symbol.destroy_table(&symbols)
module, loaded := loader.load(directory, &sources, &diagnostics, &symbols)
defer ast.destroy_module(&module)
testing.expect(t, loaded)
testing.expect_value(t, len(diagnostics.items), 0)
testing.expect_value(t, compiler_core.compile_package(directory, output), 0)
state := run_executable(output)
testing.expect_value(t, state.exit_code, 0)
}
@(test)
imported_main_does_not_satisfy_root_main_requirement :: proc(t: ^testing.T) {
output := "/tmp/brolang-test-package-missing-root-main"