diff options
author | alandonovan <adonovan@google.com> | 2019-02-06 17:49:05 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-06 17:49:05 -0500 |
commit | 6afa1bba75f9a45983861e1c3c4d28e1ee1fcfbf (patch) | |
tree | 989f2bc573e883e009da2c0d33808add8ef29da1 /starlarkstruct | |
parent | a3e7ce07be9d06608ccb310553517f8a85031cda (diff) | |
download | starlark-go-6afa1bba75f9a45983861e1c3c4d28e1ee1fcfbf.tar.gz |
resolve: report likely identifier misspellings (#138)
Move spell.go to internal/spell package to enable re-use.
Unfortunately the resolver API provides no way for it to enumerate
predeclared and universe, so these candidates are missing.
Also, change var ErrNoSuchField to type NoSuchAttrError so that
HasAttrs.Attr and HasSetField.SetField implementations can return
their own message and still benefit from spell checking.
Diffstat (limited to 'starlarkstruct')
-rw-r--r-- | starlarkstruct/struct.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/starlarkstruct/struct.go b/starlarkstruct/struct.go index 07aa84c..ac9c955 100644 --- a/starlarkstruct/struct.go +++ b/starlarkstruct/struct.go @@ -228,7 +228,8 @@ func (s *Struct) Attr(name string) (starlark.Value, error) { if s.constructor != Default { ctor = s.constructor.String() + " " } - return nil, fmt.Errorf("%sstruct has no .%s attribute", ctor, name) + return nil, starlark.NoSuchAttrError( + fmt.Sprintf("%sstruct has no .%s attribute", ctor, name)) } func (s *Struct) len() int { return len(s.entries) } |