Package typecheck contains a number of typechecking and inference utilities for bigslice operators.



    This section is empty.


    View Source
    var TestCalldepth = 0

      TestCalldepth may be overridden by a user to add call depths to errors that are constructed by NewError. This is useful for testing that error messages capture the correct locations.


      func CanApply

      func CanApply(fn slicefunc.Func, arg slicetype.Type) bool

        CanApply returns whether fn can be applied to arg.

        func Devectorize

        func Devectorize(typ slicetype.Type) (slicetype.Type, bool)

          Devectorize returns a devectorized version of the provided slicetype: Each of the type's columns is expected to be a slice; the returned type unwraps the slice from each column. If the provided type is not a valid vectorized slice type, false is returned.

          func Equal

          func Equal(expect, actual slicetype.Type) bool

            Equal tells whether the the expected and actual slicetypes are equal.

            func Location

            func Location(file string, line int)

              Location rewrites typecheck errors to use the provided location instead of the one computed by Panic. This allows a caller to attribute typechecking errors where appropriate. Location should only be used as a defer function, as it recovers (and rewrites) panics.

              file, line := ...
              defer Location(file, line)

              func Panic

              func Panic(calldepth int, message string)

                Panic constructs a typechecking error and then panics with it.

                func Panicf

                func Panicf(calldepth int, format string, args ...interface{})

                  Panicf constructs a new formatted typechecking error and then panics with it.

                  func Slices

                  func Slices(columns ...interface{}) (slicetype.Type, bool)

                    Slices returns a slicetype of the provided column values. If the passed values are not valid column values, Slices returns false.


                    type Error

                    type Error struct {
                    	Err  error
                    	File string
                    	Line int

                      Error represents a typechecking error. It wraps an underlying error with a location, as captured by NewError.

                      func Errorf

                      func Errorf(calldepth int, format string, args ...interface{}) *Error

                        Errorf constructs an error in the manner of fmt.Errorf.

                        func NewError

                        func NewError(calldepth int, err error) *Error

                          NewError creates a new typechecking error at the given calldepth. The returned Error wraps err with the caller's location.

                          func (*Error) Error

                          func (err *Error) Error() string

                            Error implements error.