From 977eb5c79ac382d67af5d9f467acee13c6e0b420 Mon Sep 17 00:00:00 2001 From: Philip Ginsbach Date: Thu, 12 Feb 2026 11:55:09 +0000 Subject: [PATCH] Avoid inconsistent implicit toString on potential string subtypes Fix cases where the compiler cannot prove types don't extend string: 1. FileSystem.qll: Add toString() to ContainerBase signature. The instantiation sites already provide toString(), so no changes needed there. Container.toString() now delegates to super.toString(). No behaviour change. 2. DataFlowImplCommon.qll: Content.toString() now delegates to super.toString() instead of returning the literal "Content". This is a behaviour change: Content now displays its actual description (e.g. field names) rather than the generic "Content". --- .../codeql/dataflow/internal/DataFlowImplCommon.qll | 2 +- shared/util/codeql/util/FileSystem.qll | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/shared/dataflow/codeql/dataflow/internal/DataFlowImplCommon.qll b/shared/dataflow/codeql/dataflow/internal/DataFlowImplCommon.qll index 288814c4c511..5882f997f18c 100644 --- a/shared/dataflow/codeql/dataflow/internal/DataFlowImplCommon.qll +++ b/shared/dataflow/codeql/dataflow/internal/DataFlowImplCommon.qll @@ -112,7 +112,7 @@ module MakeImplCommon Lang> { final private class LangContentSet = Lang::ContentSet; class Content extends LangContentSet { - string toString() { result = "Content" } + string toString() { result = super.toString() } } class ContentFilter extends Unit { diff --git a/shared/util/codeql/util/FileSystem.qll b/shared/util/codeql/util/FileSystem.qll index fe724190f746..5f9b1b657568 100644 --- a/shared/util/codeql/util/FileSystem.qll +++ b/shared/util/codeql/util/FileSystem.qll @@ -23,6 +23,13 @@ signature module InputSig { * Typically `containerparent(result, this)`. */ ContainerBase getParentContainer(); + + /** + * Gets a textual representation of this container. + * + * Typically `result = this.getAbsolutePath()`. + */ + string toString(); } /** @@ -206,7 +213,7 @@ module Make { * * This is the absolute path of the container. */ - string toString() { result = this.getAbsolutePath() } + string toString() { result = super.toString() } } /** A folder. */