Skip to content

Commit

Permalink
add more clarifying comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dsainati1 committed Nov 30, 2022
1 parent 3b037e2 commit 75b9cda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions runtime/sema/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -3606,6 +3606,8 @@ func (t *CompositeType) IsResourceType() bool {
return t.Kind == common.CompositeKindResource ||
// attachments are always the same kind as their base type
(t.Kind == common.CompositeKindAttachment &&
// this check is necessary to prevent `attachment A for A {}`
// from causing an infinite recursion case here
t.baseType != t &&
t.baseType.IsResourceType())
}
Expand Down
4 changes: 4 additions & 0 deletions runtime/sema/typeannotationstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ type TypeAnnotationState uint
const (
TypeAnnotationStateUnknown TypeAnnotationState = iota
TypeAnnotationStateValid
// Resource annotations (@) are invalid on non-resource types (e.g. @Int)
TypeAnnotationStateInvalidResourceAnnotation
// Resource types must have a resource annotation (@)
TypeAnnotationStateMissingResourceAnnotation
// attachments types must never appear directly as annotations, and instead
// should appear only in reference types: e.g. `&A` or `[&A]`
TypeAnnotationStateDirectAttachmentTypeAnnotation
)

0 comments on commit 75b9cda

Please sign in to comment.