Re: assert/static assert message format difference

2023-06-13 Thread Basile B. via Digitalmars-d-learn

On Tuesday, 13 June 2023 at 16:46:26 UTC, DLearner wrote:

Only a small thing, but is it intended that:
```
void main() {

// static assert (false, "Static Assert triggered");
   assert(false, "Assert triggered");

}
```
produces
```
core.exception.AssertError@staticassertex01.d(4): Assert 
triggered

```
but removing the // produces
```
staticassertex01.d(3): Error: static assert:  "Static Assert 
triggered"

```
ie message surrounded by double-quotes?


internal detail.

Static assert will render the message by formatting an AST node, 
i.e the StringExp (as the string has to be statically evaluable), 
using a compiler module called the hdrgen, leading to have the 
double quotes included, because the hdrgen is supposed to give 
back the source code for a particulat node.


Runtime assert only know the string ptr and len, which are 
runtime values. So... in that case it's more like a format %s, 
that takes another path.


assert/static assert message format difference

2023-06-13 Thread DLearner via Digitalmars-d-learn

Only a small thing, but is it intended that:
```
void main() {

// static assert (false, "Static Assert triggered");
   assert(false, "Assert triggered");

}
```
produces
```
core.exception.AssertError@staticassertex01.d(4): Assert triggered
```
but removing the // produces
```
staticassertex01.d(3): Error: static assert:  "Static Assert 
triggered"

```
ie message surrounded by double-quotes?