Stream: contributing

Topic: Use yellow underline in warnings #6771


view this post on Zulip John Konecny (Jun 02 2024 at 15:43):

For issue 6771, the function region_with_subregion in crates/reporting/src/report.rs seems to be responsible for determining the color of the text. I was thinking about adding theSeverity enum in crates/compiler/problem/src/lib.rs, but since so many functions have both direct and indirect dependencies on region_with_subregion it is turning into a massive change. Is there a better way to do this or is there only pain when it comes to making this change? :laughing:

    pub fn region_with_subregion(
        &'a self,
        region: LineColumnRegion,
        sub_region: LineColumnRegion,
    ) -> DocBuilder<'a, Self, Annotation> {
...
        if error_highlight_line {
            let highlight_text = ERROR_UNDERLINE
                .repeat((sub_region.end().column - sub_region.start().column) as usize);

            let highlight_line = self
                .line()
                // Omit the gutter bar when we know there are no further
                // line numbers to be printed after this!
                .append(self.text(" ".repeat(max_line_number_length + GUTTER_BAR_WIDTH)))
                .append(if highlight_text.is_empty() {
                    self.nil()
                } else {
                    self.text(" ".repeat(sub_region.start().column as usize))
                        .indent(indent)
                        .append(self.text(highlight_text).annotate(Annotation::Error))
                });

            result = result.append(highlight_line);
        }
...
}

view this post on Zulip Anton (Jun 06 2024 at 17:35):

Thanks for looking into this @John Konecny, I do indeed believe a large amount of changes is necessary.

view this post on Zulip John Konecny (Jun 08 2024 at 10:27):

Thanks for the clarification! By the way it’s all good if someone beats me to this fix.

view this post on Zulip John Konecny (Jun 09 2024 at 19:30):

@Anton
https://github.com/roc-lang/roc/pull/6794

view this post on Zulip Luke Boswell (Jun 10 2024 at 00:26):

I kicked off CI for this


Last updated: Jul 06 2025 at 12:14 UTC