Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sending at:put: to an undefined object (nil) give confusing error message #2795

Closed
macta opened this Issue Mar 11, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@macta
Copy link
Contributor

macta commented Mar 11, 2019

If you forget to initialise a variable you thought was a Dictionary - you get a confusing error message: "Error: only integers should be used as indices"

This is a consequence of having at:put: defined on Object (which is a bit nasty)

Should UndefinedObject at least override this and signal something a bit more obvious? This is a common easily done thing and we don't support it very well.

I just did it in some code, and was scratching my head initially until I read the stack properly and realised it was something much simpler than I thought I had done.

@bencoman

This comment has been minimized.

Copy link
Contributor

bencoman commented Mar 11, 2019

This may be a good one for broader discussion on the mail list.

@macta

This comment has been minimized.

Copy link
Contributor Author

macta commented Mar 12, 2019

Good point - i'm sure that will rage on for a bit... but best to get some input.

@macta

This comment has been minimized.

Copy link
Contributor Author

macta commented Mar 12, 2019

From ML: Richard gives a nice test scenario:

I understand #basicAt:[put:] being in Object, but I never understood #at:[put:] being there.
GNU Smalltalk:
st> nil at: 1
Object: nil error: Invalid value nil: object not indexable

In my Smalltalk, you get a DNU.

In Squeak you get a debugger window with title
Error: instances of UndefinedObject are not indexable
The same for Boolean, Character, and Integer,
except Squeak where (20 factorial at: 1) answers 0 (oh dear oh dear oh dear).

In VW you get a "Subscript out of bounds" error, which is disappointing,
as do true and $a, but a LargePositiveinteger gets #shouldNotImplement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.