move hide behind @ and specify with :

This commit is contained in:
2026-08-10 22:45:41 +02:00
parent 5244bfbf1b
commit ba6052eef3
27 changed files with 162 additions and 149 deletions
+21 -19
View File
@@ -3194,7 +3194,7 @@ main func() void! {
B :: enum { b }
fail_a func() void ! A { return .a }
fail_b func() void ! B { return .b }
hide dispatch func(selector i32) void! {
@hide dispatch func(selector i32) void! {
if selector == 1 {
try fail_a()
return
@@ -3265,7 +3265,7 @@ main func() void {}
{
source=`Error :: enum { failed }
fail func() void ! Error { return .failed }
hide untyped func(flag bool) void! {
@hide untyped func(flag bool) void! {
if flag {
try fail()
return
@@ -3277,7 +3277,7 @@ main func() void { untyped(false) catch |_| {} }
message="inferred error returns require a concretely typed error value",
},
{
source=`hide empty func() void! {}
source=`@hide empty func() void! {}
main func() void { empty() catch |_| {} }
`,
message="could not infer a named error channel for 'empty'",
@@ -3577,11 +3577,11 @@ system func() Io { return Io {value = 0} }
process_source=`io :: import "@std/io"
Init :: struct { io io.Io }
`,
message="does not provide the required 'hide system func() Io'",
message="does not provide the required '@hide system func() Io'",
},
{
io_source=`Io :: struct { value i32 }
hide system func() Io { return Io {value = 0} }
@hide system func() Io { return Io {value = 0} }
`,
process_source=`io :: import "@std/io"
Init :: struct { io io.Io, extra i32 }
@@ -10366,16 +10366,16 @@ imports_are_file_local :: proc(t: ^testing.T) {
@(test)
visibility_modifiers_are_rejected_outside_named_top_level_declarations :: proc(t: ^testing.T) {
cases := [?]string{
`hide import "../dep"`,
`hide(file) dep :: import "../dep"`,
`hide func() void {}`,
`main func(hide value i32) void {}`,
`Box :: struct { hide i32 }`,
`main func() void { hide value i32 := 1 }`,
`hide() value :: 1`,
`hide(module) value :: 1`,
`hide("file") value :: 1`,
`hide(file value :: 1`,
`@hide import "../dep"`,
`@hide:file dep :: import "../dep"`,
`@hide func() void {}`,
`main func(@hide value i32) void {}`,
`Box :: struct { @hide i32 }`,
`main func() void { @hide value i32 := 1 }`,
`@hide: value :: 1`,
`@hide:module value :: 1`,
`@hide:"file" value :: 1`,
`@hide(file) value :: 1`,
}
for text in cases {
source_file := source.Source{path="test.bro", text=text}
@@ -10568,7 +10568,7 @@ MaybePoint :: alias ?@dep.Point
Concrete :: alias dep.Box(i32)
`
hidden_text := `dep :: import "../dep"
hide local_answer_alias :: alias dep.answer
@hide local_answer_alias :: alias dep.answer
`
top_text := `facade :: import "../facade"
Box :: alias facade.RenamedBox
@@ -10692,7 +10692,7 @@ declaration_aliases_diagnose_invalid_targets :: proc(t: ^testing.T) {
testing.expect(t, os.make_directory(directory) == nil)
}
dep_text := `visible func() i32 { return 1 }
hide hidden_target func() i32 { return 2 }
@hide hidden_target func() i32 { return 2 }
ambiguous func() i32 { return 3 }
ambiguous i32 :: 4
`
@@ -14165,7 +14165,6 @@ main func() i32 {
@(test)
keywords_are_valid_enum_members_and_tagged_union_variants :: proc(t: ^testing.T) {
testing.expect(t, token.is_keyword(.Keyword_Func))
testing.expect(t, token.is_keyword(.Keyword_Hide))
testing.expect(t, token.is_keyword(.Keyword_C_Longdouble))
testing.expect(t, !token.is_keyword(.Identifier))
testing.expect(t, !token.is_keyword(.Underscore))
@@ -14180,6 +14179,9 @@ Token :: union(TokenKind) {
else void
return i32
}
hide func() i32 { return 0 }
package func() i32 { return 0 }
file func() i32 { return 0 }
kind func(value bool) TokenKind {
if value {
return .if
@@ -14192,7 +14194,7 @@ main func() i32 {
a Token := Token{ if = 1 }
b Token := Token{ else }
c Token := .return{2}
total i32 := a.if + c.return
total i32 := a.if + c.return + hide() + package() + file()
match first {
.if: total = total + 1
.else: total = total + 2