REBOL3 tracker
  0.9.12 beta
Ticket #0001363 User: anonymous

Project:



rss
TypeIssue Statustested Date29-Nov-2009 09:58
Versionalpha 95 CategoryError Handling Submitted bymeijeru
PlatformAll Severitytext Prioritynormal

Summary ASSERT/TYPE gives strange error message when testing literals
Description It may be less than useful to do a type assertion on a literal value, which is why the documentation forbids it. But the user should not be be unduly puzzled by the error message given out.

Also, it is perfectly legal to use ASSERT without /TYPE on a literal value, which is not more useful.
Example code
>> assert/type [1 integer!]
** Script error: integer! type is not allowed here
>> assert [1]
== true

Assigned ton/a Fixed inalpha 97 Last Update8-Feb-2010 01:31


Comments
(0001835)
BrianH
29-Nov-2009 12:44

Edited the summary to reflect that it is the weird error message that is the issue, not the behavior of ASSERT.

ASSERT without type just evaluates the expressions in its argument block like ALL does. It would be more difficult to make it not accept literals. However, I have every confidence that some clever developer will find some amazing reason why this behavior will be useful (probably involving code generation), so there is really no point to go out of our way to make it not work :)
(0001836)
meijeru
29-Nov-2009 17:26

You have now inspired me to suggest that -- if is is easier to program -- one could allow testing the type of a general expression. Imagine the value being the result of a LOAD, e.g.; this could no doubt be used by another clever developer for some purpose.
(0001838)
meijeru
1-Dec-2009 08:53

BTW, is there any -- operational -- difference between ASSERT/TYPE [a integer!] and ASSERT [integer? a]. If not, isn't the /TYPE refinement superfluous?
(0001839)
BrianH
2-Dec-2009 08:36

Yes: ASSERT/type is faster because it doesn't evaluate expressions, and it is safer too.
(0001983)
Carl
7-Feb-2010 00:32

Now:
>> assert/type [1 integer!]
** Script error: invalid argument: 1

Generally, ASSERT (w/o /type) is for general expressions. ASSERT/TYPE is for the format similar to that of formal function argument specs (but still a subset.)

Date User Field Action Change
8-Feb-2010 01:31 BrianH Status Modified built => tested
7-Feb-2010 00:35 Carl Comment : 0001983 Modified -
7-Feb-2010 00:33 Carl Status Modified reviewed => built
7-Feb-2010 00:33 Carl Fixedin Modified => alpha 97
7-Feb-2010 00:32 Carl Comment : 0001983 Added -
2-Dec-2009 08:36 BrianH Comment : 0001839 Added -
1-Dec-2009 08:53 meijeru Comment : 0001838 Added -
29-Nov-2009 17:26 meijeru Comment : 0001836 Added -
29-Nov-2009 12:44 BrianH Comment : 0001835 Added -
29-Nov-2009 12:37 BrianH Status Modified submitted => reviewed
29-Nov-2009 12:37 BrianH Severity Modified minor => text
29-Nov-2009 12:37 BrianH Category Modified Native => Error Handling
29-Nov-2009 12:37 BrianH Summary Modified ASSERT/TYPE does not accept literals, gives strange error message => ASSERT/TYPE gives strange error message when testing literals
29-Nov-2009 10:01 meijeru Type Modified Bug => Issue
29-Nov-2009 10:01 meijeru Code Modified -
29-Nov-2009 10:01 meijeru Description Modified -
29-Nov-2009 09:58 meijeru Ticket Added -