Skip to content

Commit a099a52

Browse files
committed
Type declaration is now optional
1 parent 3c58427 commit a099a52

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

gen/type.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ import (
1515
// It either (1) a builtin type or (2) a type alias declared by the "type"
1616
// keyword.
1717
type NamedTypeInfo struct {
18-
Name string
19-
Size core.UsmUint
20-
Declaration core.UnmanagedSourceView
18+
Name string
19+
Size core.UsmUint
20+
21+
// The source view of the type declaration.
22+
// Should be nil only if it is a builtin type.
23+
Declaration *core.UnmanagedSourceView
2124
}
2225

2326
type TypeDescriptorType uint8
@@ -305,7 +308,7 @@ func (g *NamedTypeGenerator[InstT]) Generate(
305308
{
306309
Type: core.HintResult,
307310
Message: "Previous definition here",
308-
Location: &typeInfo.Declaration,
311+
Location: typeInfo.Declaration,
309312
},
310313
})
311314
}
@@ -329,7 +332,7 @@ func (g *NamedTypeGenerator[InstT]) Generate(
329332
typeInfo = &NamedTypeInfo{
330333
Name: identifier,
331334
Size: referencedTypeInfo.Size,
332-
Declaration: declaration,
335+
Declaration: &declaration,
333336
}
334337

335338
result := ctx.Types.NewType(typeInfo)

gen/utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func (m *TypeMap) newBuiltinType(name string, size core.UsmUint) core.Result {
2626
info := &gen.NamedTypeInfo{
2727
Name: name,
2828
Size: size,
29-
Declaration: core.UnmanagedSourceView{},
29+
Declaration: &core.UnmanagedSourceView{},
3030
}
3131
return m.NewType(info)
3232
}

0 commit comments

Comments
 (0)