Skip to content

Propagate uint32 arguments types in ast #432

Closed
@hesining

Description

@hesining
package main

import (
	"fmt"
	"github.com/antonmedv/expr"
)

type Tweet struct {
	Len int
}

type Env struct {
	Tweets []Tweet
}

func (e *Env) IsTestXXX(objID uint32) (rslt bool) {
	fmt.Println(objID)
	return true
}

func main() {
	code := `IsTestXXX(111)`

	env := &Env{
		Tweets: []Tweet{{42}, {98}, {69}},
	}

	program, err := expr.Compile(code, expr.Env(env))
	if err != nil {
		panic(err)
	}

	fmt.Println(program.Source.Content())

	output, err := expr.Run(program, env)
	if err != nil {
		panic(err)
	}

	fmt.Println(output)
}

receve error msg

panic: cannot use int as argument (type uint32) to call IsTestXXX  (1:11)
 | IsTestXXX(111)                                                        
 | ..........^    

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions