bigslice: Index | Files

package typecheck

import ""

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


Package Files

error.go func.go typecheck.go


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 Devectorize Uses

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 Uses

func Equal(expect, actual slicetype.Type) bool

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

func Func Uses

func Func(x interface{}) (arg, ret slicetype.Type, ok bool)

Func deconstructs a function's argument and return types into slicetypes. If x is not a function, Func returns false.

If the type of the first argument to the provided function is context.Context, then it is ignored: the returned type contains only the remainder of the arguments.

func Location Uses

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 Uses

func Panic(calldepth int, message string)

Panic constructs a typechecking error and then panics with it.

func Panicf Uses

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

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

func Slices Uses

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 Uses

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 Uses

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

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

func NewError Uses

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 Uses

func (err *Error) Error() string

Error implements error.

Package typecheck imports 6 packages (graph) and is imported by 5 packages. Updated 2019-11-21. Refresh now. Tools for package owners.