maybe "assert" shouldnt always show the constraint #3725
Comments
[@RossTate] This may also be a problem for those trying to keep their code a secret. |
[@loicrouchon] I like the way assert is writing the failing condition but given your example (a clear
The second solution would maybe be more flexible than the first one, but I don't really know what we should (or not) do |
[@tombentley] A third option would be a compiler option to disable inclusion of the violated condition. That would probably be preferred by those seeking secrecy because it would let them set it in one place, rather than having to remember something every time they used |
This makes more sense to me. At development time, which is when we usually see assertions, it's really useful to see the expression. Once we distribute the app or library, the But from my point of view the biggest issue here remains that we can't do interpolation into the assertion failure message. |
Well isn't that because we're abusing the The problem here was syntax, as I recall. We could use something like |
[@gavinking]
Though the fat arrow would not really be necessary. |
[@gavinking] Perhaps this:
|
[@tombentley] My immediate reaction was "yeah, that's great!", followed moments later by the following doubts:
I think I still prefer it over |
[@gavinking] @tombentley We already allow |
[@tombentley] Sure but that's in an expression, so it makes intuitive sense. Now the rule about when |
[@gavinking] Thinking through this issue a little further, I'm not convinced its a real problem. Assertions failures represent bugs, i.e. programming errors. I don't see why you would ever need to hide the expression given that the audience is always the programmer. And I don't attach any weight on this "people trying to keep their code secret" argument. that one doesn't make a whole lot of sense. I'm inclined to close this. |
[@tombentley] The audience is not always the programmer; the bug might not be discovered until the software is shipped/deployed/whatever. If some code makes it into production with such a bug present, a user who discovers the bug can also provoke the program into revealing a little bit of information about the source code (and something the programmer believed was true, that isn't). I that extra information could in principal help turn a plain bug into a bug with security implications. |
[@gavinking] The eventual audience is the programmer. And I don't buy your scenario at all. If you are in the habit of displaying stack traces to users (I'm not), then there's already a whole lot of information there. it's not like this is a dynamic lang where perhaps the user could take advantage of knowing some local var names to do eval or something. |
[@DiegoCoronel] Hi,
lets say i have this assert:
and i want to use the method:
time( 25, 0);
in this case its not a valid hour and the message i got from AssertException is:so, why do we need to know the assert that caused it? isnt this internally ?
in above case isnt so bad: violated hours >= 0 && hours < h.perDay
but i think there will be cases with xxx[2] < yyy.xor(123)... some calc with no sense for the caller (developer)
isnt better show only the doc when its avaiable?
[Migrated from ceylon/ceylon-spec#619]
The text was updated successfully, but these errors were encountered: