# \--warn-param-implicit-conversions

**URL:** <https://chapel.discourse.group/t/warn-param-implicit-conversions/42382>\
**Category:** Users\
**Created:** [April 20, 2025, 3:59am UTC](https://chapel.discourse.group/t/warn-param-implicit-conversions/42382 "2025-04-20T03:59:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![damianmoz](https://yyz2.discourse-cdn.com/free1/user_avatar/chapel.discourse.group/damianmoz/32/319_2.png) [@damianmoz](https://chapel.discourse.group/u/damianmoz)\
**Post date:** [April 20, 2025, 3:59am UTC](https://chapel.discourse.group/t/warn-param-implicit-conversions/42382/1 "2025-04-20T03:59:58Z")

</div>

Given _b_ and _p_ both **uint** (32) and _b_ \>\> _p_ \>\> 1, then compiling

```chapel
 param B = 10 + b / 2 - (p - 1) / 2;
 param k = (b + 1) / 4 + v:uint(32) / 2;

```

with the above flag is silent. It should complain a lot because it does things like make the types of both those **param** s have a type of **int** , These numbers are associated with **real** (w) numbers.

For a **real** (32), (b, p, v) is (127, 24, 32). For **real** (64) that tuple is (1023, 53, 64)

What am I missing please? Or is it just silly me ,,, again. Chapel is 2.0.0.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![damianmoz](https://yyz2.discourse-cdn.com/free1/user_avatar/chapel.discourse.group/damianmoz/32/319_2.png) [@damianmoz](https://chapel.discourse.group/u/damianmoz)\
**Post date:** [April 21, 2025, 11:54am UTC](https://chapel.discourse.group/t/warn-param-implicit-conversions/42382/2 "2025-04-21T11:54:52Z")

</div>

I changed it to

```chapel
param B = 9 + b >> 1 - (p - 1) >> 1;
param k = (b + 1) >> 2 + v >> 1;

```

and the problem with B went away. Not quite sure why.

I can understand that `v >> 1` is an **int** (64) because `v` itself is an **int** (64) but I do not understand why the increment of _b_ is not a **uint** (32) given that _b_ is a **uint** (32).

Mind you, still none the wiser about the lack of warnings.

---

<div class="post-metadata">

**Author:** ![damianmoz](https://yyz2.discourse-cdn.com/free1/user_avatar/chapel.discourse.group/damianmoz/32/319_2.png) [@damianmoz](https://chapel.discourse.group/u/damianmoz)\
**Post date:** [April 22, 2025, 9:07am UTC](https://chapel.discourse.group/t/warn-param-implicit-conversions/42382/3 "2025-04-22T09:07:04Z")

</div>

None of these warning messages work. How do I turn them on?

Do integral literals ever affect the type of an expression, change the type to something different to that determined by the identifiers in the expression?

I just spent a day putting type debug statements throughout code to figure out where I had a bug.

Also, what is are the rules about index variables. Sometimes I can use either signed or unsigned integers as an index. Other times, the compiler complains.

Thanks.

---

<div class="post-metadata">

**Author:** ![damianmoz](https://yyz2.discourse-cdn.com/free1/user_avatar/chapel.discourse.group/damianmoz/32/319_2.png) [@damianmoz](https://chapel.discourse.group/u/damianmoz)\
**Post date:** [April 23, 2025, 2:54am UTC](https://chapel.discourse.group/t/warn-param-implicit-conversions/42382/4 "2025-04-23T02:54:35Z")

</div>

The need for these warning is tracking down what I believe are errors n Chapel's implicit type promotions. Or errors in my own code. For example, given a small **param**** uint**(32), actually 127, I cannot understand why the expression

```chapel
param j = b + 1;

```

has type **int** (64). Baffling. I cannot reproduce the error in a small piece of code. Very lost.

Code chunk:

```chapel
            param B = (9 + (b / 2) - (p - 1) / 2):U;
            param j = b + 1;
            param l = v / 2;
            param k = (j/ 4 + l):U;
            // param k = ((b + 1) / 4 + v / 2):U;
            param _U = _reifyExponent(b + B);
            param _L = _reifyExponent(b - B);
            const hf2 : R; // the blend of half * f2

            assert(b.type == uint(32));
            assert(v.type == uint(32));
            assert(j.type == int(64));
            assert(l.type == int(64));

```

Sorry I used the variable name of lower case L.

---

<div class="post-metadata">

**Author:** ![bradcray](https://yyz2.discourse-cdn.com/free1/user_avatar/chapel.discourse.group/bradcray/32/72_2.png) [@bradcray](https://chapel.discourse.group/u/bradcray)\
**Post date:** [April 23, 2025, 3:09am UTC](https://chapel.discourse.group/t/warn-param-implicit-conversions/42382/5 "2025-04-23T03:09:54Z")

</div>

Hi Damian —

I haven't had the time to fully digest this thread and attempt to turn your examples into compilable codes (and don't tonight either), but I think the issue as to why you aren't getting warnings may relate to the `--warn-param-implicit-numeric-conversions` flag wanting other flags to also be used to specify which types of conversions you want to be warned of.

Specifically, [see this part of the man page](https://chapel-lang.org/docs/usingchapel/man.html#man-warn-param-implicit-numeric-conversions):

> ```
> When used in conjunction with warn-int-uint, --warn-real-real, or
> --warn-integral-integral, this flag enables [or disables] these
> compilation warnings about implicitly converting between numeric
> types to also apply when the converted value is a param.
> 
> ```

I've been bit by this before as well ("Where's my output?") and think it would be reasonable to have the compiler issue a warning if the one flag is used but none of the accompanying supporting flags are (or at least, I don't know of a reason why such a warning would be a bad idea).

I think this could be worth an issue if you find it to be the cause of your confusion and agree.

As for rationalizing the behavior, I'll need more cycles for that, or hope someone else will beat me to it,  
-Brad

---

<div class="post-metadata">

**Author:** ![damianmoz](https://yyz2.discourse-cdn.com/free1/user_avatar/chapel.discourse.group/damianmoz/32/319_2.png) [@damianmoz](https://chapel.discourse.group/u/damianmoz)\
**Post date:** [April 23, 2025, 3:44am UTC](https://chapel.discourse.group/t/warn-param-implicit-conversions/42382/6 "2025-04-23T03:44:53Z")

</div>

Thanks. I will investigate further, I thought the Easter bunny had run off with my brain.

---

<div class="post-metadata">

**Author:** ![damianmoz](https://yyz2.discourse-cdn.com/free1/user_avatar/chapel.discourse.group/damianmoz/32/319_2.png) [@damianmoz](https://chapel.discourse.group/u/damianmoz)\
**Post date:** [April 23, 2025, 11:46am UTC](https://chapel.discourse.group/t/warn-param-implicit-conversions/42382/7 "2025-04-23T11:46:23Z")

</div>

Thanks. That got me the messages.

I will post some further detail about the source of my confusion. However it is related to the fact that the type of the expression

```chapel
p + 1

```

does not necessarily have the type of `p` and the type of expression

```chapel
v - 1

```

does not necessarily have the type of `v` whereas the type of the expression

```chapel
7 - 2 * j

```

has the type of j.

The type of each of the **param** s `v` and `p` above is **uint** (32) while that of the **const** `j` is **int** (32).

---

<div class="post-metadata">

**Author:** ![damianmoz](https://yyz2.discourse-cdn.com/free1/user_avatar/chapel.discourse.group/damianmoz/32/319_2.png) [@damianmoz](https://chapel.discourse.group/u/damianmoz)\
**Post date:** [April 25, 2025, 4:58am UTC](https://chapel.discourse.group/t/warn-param-implicit-conversions/42382/8 "2025-04-25T04:58:54Z")

</div>

Part of the problem is my reading of that table about Implicit conversions. My head hurts.

I will document the underlying problem in an issue. Maybe this weekend. Maybe next.

I figured out those integer warning options.
