# Stdout "not equal to itself"?

**URL:** <https://chapel.discourse.group/t/stdout-not-equal-to-itself/46825>\
**Category:** Users\
**Created:** [December 20, 2025, 3:55pm UTC](https://chapel.discourse.group/t/stdout-not-equal-to-itself/46825 "2025-12-20T15:55:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nelsonluisdias](https://yyz2.discourse-cdn.com/free1/user_avatar/chapel.discourse.group/nelsonluisdias/32/691_2.png) [@nelsonluisdias](https://chapel.discourse.group/u/nelsonluisdias)\
**Post date:** [December 20, 2025, 3:55pm UTC](https://chapel.discourse.group/t/stdout-not-equal-to-itself/46825/1 "2025-12-20T15:55:50Z")

</div>

Hello: I would expect the code below,

```chapel
use IO;
var f = stdout;
f.writeln("hello");
again(f);
proc again(
   const in g: fileWriter(true)
   ) {
   if g == stdout {
      g.writeln("hello again");
   }
}

```

to print two lines:

```Chapel
hello
hello again

```

But it only prints the first. I would appreciate to know why 🙂

---

<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:** [December 20, 2025, 5:29pm UTC](https://chapel.discourse.group/t/stdout-not-equal-to-itself/46825/2 "2025-12-20T17:29:55Z")

</div>

Hi Nelson —

This looks like a bug to me, as I'd expect the same behavior as you.

Digging into it a little bit, it appears to me that it's a result of internal fields of the fileWriter type not being identical and/or the type (or its field types) not defining a custom `==` operator to deal with that fact, but I am not 100% confident. If you would open a [bug report issue](https://github.com/chapel-lang/chapel/issues) for this on our GitHub repository, I think that would be ideal. Note that most of our team at HPE is off for the next few weeks, so a fix would probably happen in the new year.

Notes for developers: I added the following writeln()s to Nelson's code:

```Chapel
   writeln((g.locking, stdout.locking));
   writeln(g.locking == stdout.locking);
   writeln((g.serializerType:string, stdout.serializerType:string));
   writeln(g._serializer.type:string ==stdout._serializer.type:string);
   writeln(g._serializer == stdout._serializer);
   writeln((g._home.id, stdout._home.id));
   writeln(g._home == stdout._home);
   writeln((g._channel_internal, stdout._channel_internal));
   writeln(g._channel_internal == stdout._channel_internal);
   writeln((g._readWriteThisFromLocale, stdout._readWriteThisFromLocale));
   writeln(g._readWriteThisFromLocale == stdout._readWriteThisFromLocale);

```

and got a `false` for the comparison between serializers. I started to look into adding a custom `==` operator for `_serializeWrapper` or comparing the objects and individual `_serializeWrapper` fields, but timed out before completing.

-Brad

---

<div class="post-metadata">

**Author:** ![nelsonluisdias](https://yyz2.discourse-cdn.com/free1/user_avatar/chapel.discourse.group/nelsonluisdias/32/691_2.png) [@nelsonluisdias](https://chapel.discourse.group/u/nelsonluisdias)\
**Post date:** [December 20, 2025, 7:39pm UTC](https://chapel.discourse.group/t/stdout-not-equal-to-itself/46825/3 "2025-12-20T19:39:52Z")

</div>

Thanks Brad: I just filed bug issue #28247.

Regards

Nelson

---

<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:** [January 12, 2026, 6:39am UTC](https://chapel.discourse.group/t/stdout-not-equal-to-itself/46825/4 "2026-01-12T06:39:52Z")

</div>

Hi Nelson —

Thanks very much for filing this issue. This should be fixed on `main`, now, though please be sure to read the note in [[Bug]: fileWriter argument checks false against stdout, when it should be true · Issue #28247 · chapel-lang/chapel · GitHub](https://github.com/chapel-lang/chapel/issues/28247#issuecomment-3720810025) if you haven't already, which has some suggestions for arguably better / less ambiguous style for this pattern for consideration and the related issue [Should copying a fileReader/Writer "alias" the original or produce a new one (e.g., with unique cursor) · Issue #28268 · chapel-lang/chapel · GitHub](https://github.com/chapel-lang/chapel/issues/28268) that it refers to.

Thanks again, and best wishes,  
-Brad

---

<div class="post-metadata">

**Author:** ![nelsonluisdias](https://yyz2.discourse-cdn.com/free1/user_avatar/chapel.discourse.group/nelsonluisdias/32/691_2.png) [@nelsonluisdias](https://chapel.discourse.group/u/nelsonluisdias)\
**Post date:** [January 12, 2026, 2:02pm UTC](https://chapel.discourse.group/t/stdout-not-equal-to-itself/46825/5 "2026-01-12T14:02:37Z")

</div>

Thanks Brad. I still have the (bad) habit of declaring vars where more accurately objects should be consts. This is clearly the case when dealing with a single fileReader/Writer that only needs to be opened, read/written, and closed. I believe I can trace this habit of mine back to a time when "consts" in pascal were most of the time integer or real consts, and in C were macros with #defines --- not to mention that in Fortran 66/77 the concept was even fuzzier. Of course, one can now declare a constant file pointer in C, or constant file reader / writer in Chapel, etc. Which teaches me that more structured objects such as arrays, records and files should be declared constant whenever possible. Regards,

Nelson

---

<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:** [January 12, 2026, 7:00pm UTC](https://chapel.discourse.group/t/stdout-not-equal-to-itself/46825/6 "2026-01-12T19:00:18Z")

</div>

Hi Nelson —

Makes sense and I'm always happy to find a kindred spirit in Pascal.

Note, though, that it's the `ref` aspect of that comment that's key rather than the `const` aspect, as a means of saying "I'd like to refer to this existing thing rather than creating something new). The `const` is also necessary because `stdout` is a `const`, and Chapel won't permit a (modifiable) `ref` to refer to a `const` declaration, so `const ref` keeps the reference read-only.

Happy 2026,  
-Brad
