Import function type check at validation phrase (#1281)

Import function type check at compilation

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
Takeshi Yoneda
2023-03-24 01:10:18 -07:00
committed by GitHub
parent 244c5c5792
commit d0fc0c6232
5 changed files with 37 additions and 26 deletions

View File

@@ -585,6 +585,12 @@ func TestModule_validateImports(t *testing.T) {
enabledFeatures: api.CoreFeaturesV1,
i: &Import{Module: "m", Name: "n", Type: ExternTypeFunc, DescFunc: 0},
},
{
name: "func type index out of range ",
enabledFeatures: api.CoreFeaturesV1,
i: &Import{Module: "m", Name: "n", Type: ExternTypeFunc, DescFunc: 100},
expectedErr: "invalid import[\"m\".\"n\"] function: type index out of range",
},
{
name: "global var disabled",
enabledFeatures: api.CoreFeaturesV1.SetEnabled(api.CoreFeatureMutableGlobal, false),
@@ -621,7 +627,7 @@ func TestModule_validateImports(t *testing.T) {
for _, tt := range tests {
tc := tt
t.Run(tc.name, func(t *testing.T) {
m := Module{}
m := Module{TypeSection: []FunctionType{{}}}
if tc.i != nil {
m.ImportSection = []Import{*tc.i}
}