generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: monomorphising would fail under some circumstances (#880)
I originally intended to replace `DataRef` references to type parameters, with concrete `TypeParameter` instances, but this ended up conflating the parameter declaration and the reference. Instead, it's now left as a `DataRef`, and I've made `TypeParameter` no longer implement `Type`. Note that it being a `DataRef` doesn't make much sense either, because it's not a data structure, but that's part of a large issue where data references can also refer to verbs within the schema parsing. The correct solution here is to use an untyped `Ref` everwhere and resolve these to the correct reference types when validating. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
2e61718
commit bcbf8f7
Showing
12 changed files
with
48 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,111 +1,41 @@ | ||
package schema | ||
|
||
import ( | ||
"golang.design/x/reflect" | ||
) | ||
import "golang.design/x/reflect" | ||
|
||
// BuiltinsSource is the schema source code for built-in types. | ||
const BuiltinsSource = ` | ||
// Built-in types for FTL. | ||
builtin module builtin { | ||
// HTTP request structure used for HTTP ingress verbs. | ||
data HttpRequest<Body> { | ||
method String | ||
path String | ||
pathParameters {String: String} | ||
query {String: [String]} | ||
headers {String: [String]} | ||
body Body | ||
} | ||
// HTTP response structure used for HTTP ingress verbs. | ||
data HttpResponse<Body> { | ||
status Int | ||
headers {String: [String]} | ||
body Body | ||
} | ||
data Empty {} | ||
} | ||
` | ||
|
||
var builtinsModuleParsed = func() *Module { | ||
module, err := moduleParser.ParseString("", BuiltinsSource) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return module | ||
}() | ||
|
||
// Builtins returns a [Module] containing built-in types. | ||
func Builtins() *Module { | ||
return reflect.DeepCopy(&Module{ | ||
Comments: []string{ | ||
"Built-in types for FTL.", | ||
}, | ||
Builtin: true, | ||
Name: "builtin", | ||
Decls: []Decl{ | ||
&Data{ | ||
Comments: []string{ | ||
"HTTP request structure used for HTTP ingress verbs.", | ||
}, | ||
Name: "HttpRequest", | ||
TypeParameters: []*TypeParameter{ | ||
{ | ||
Name: "Body", | ||
}, | ||
}, | ||
Fields: []*Field{ | ||
{ | ||
Comments: []string{}, | ||
Name: "method", | ||
Type: &String{}, | ||
}, | ||
{ | ||
Comments: []string{}, | ||
Name: "path", | ||
Type: &String{}, | ||
}, | ||
{ | ||
Comments: []string{}, | ||
Name: "pathParameters", | ||
Type: &Map{ | ||
Key: &String{}, | ||
Value: &String{}, | ||
}, | ||
}, | ||
{ | ||
Comments: []string{}, | ||
Name: "query", | ||
Type: &Map{ | ||
Key: &String{}, | ||
Value: &Array{ | ||
Element: &String{}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
Comments: []string{}, | ||
Name: "headers", | ||
Type: &Map{ | ||
Key: &String{}, | ||
Value: &Array{ | ||
Element: &String{}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
Comments: []string{}, | ||
Name: "body", | ||
Type: &TypeParameter{ | ||
Name: "Body", | ||
}, | ||
}, | ||
}, | ||
}, | ||
&Data{ | ||
Comments: []string{ | ||
"HTTP response structure used for HTTP ingress verbs.", | ||
}, | ||
Name: "HttpResponse", | ||
TypeParameters: []*TypeParameter{ | ||
{ | ||
Name: "Body", | ||
}, | ||
}, | ||
Fields: []*Field{ | ||
{ | ||
Comments: []string{}, | ||
Name: "status", | ||
Type: &Int{}, | ||
}, | ||
{ | ||
Comments: []string{}, | ||
Name: "headers", | ||
Type: &Map{ | ||
Key: &String{}, | ||
Value: &Array{ | ||
Element: &String{}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
Comments: []string{}, | ||
Name: "body", | ||
Type: &TypeParameter{ | ||
Name: "Body", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
return reflect.DeepCopy(builtinsModuleParsed) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters