implement string conversion of booleans v1 APPLIED

Eli Schwartz: 1
 implement string conversion of booleans

 1 files changed, 7 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~lattis/muon/patches/25423/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH] implement string conversion of booleans Export this patch

This is often used for e.g. message() with somevar.found() or
get_option('myfeature').enabled() formatted into it, which is the
traditional way to do old-style summary() before summary() itself was
implemented. Because bools are quite common for representing state.
 src/coerce.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/coerce.c b/src/coerce.c
index a7ae2bc..bbf92d1 100644
--- a/src/coerce.c
+++ b/src/coerce.c
@@ -13,6 +13,13 @@ coerce_string(struct workspace *wk, uint32_t node, uint32_t val, const char **re
	struct obj *v = get_obj(wk, val);
	switch (v->type) {
	case obj_bool:
		if (v->dat.boolean) {
			*res = "true";
		} else {
			*res = "false";
	case obj_file:
		*res = wk_file_path(wk, val);
I think this is could be a good change, but it won't fix calling message
with a bool.  Currently the definition for message() typechecks the
argument to be a string, so has no need to call coerce_string.

Currently coerce_string is only called during string.format() and
configure_file().  I had the above restriction put in place for these
functions as well, but testing revealed that meson will coerce numbers
and files to strings when substituting values.

That being said, I am happy to merge this, but I'm worried it might have
unintended consequences.