Skip to content

Commit 977eb5c

Browse files
committed
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".
1 parent a945f15 commit 977eb5c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

shared/dataflow/codeql/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
112112
final private class LangContentSet = Lang::ContentSet;
113113

114114
class Content extends LangContentSet {
115-
string toString() { result = "Content" }
115+
string toString() { result = super.toString() }
116116
}
117117

118118
class ContentFilter extends Unit {

shared/util/codeql/util/FileSystem.qll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ signature module InputSig {
2323
* Typically `containerparent(result, this)`.
2424
*/
2525
ContainerBase getParentContainer();
26+
27+
/**
28+
* Gets a textual representation of this container.
29+
*
30+
* Typically `result = this.getAbsolutePath()`.
31+
*/
32+
string toString();
2633
}
2734

2835
/**
@@ -206,7 +213,7 @@ module Make<InputSig Input> {
206213
*
207214
* This is the absolute path of the container.
208215
*/
209-
string toString() { result = this.getAbsolutePath() }
216+
string toString() { result = super.toString() }
210217
}
211218

212219
/** A folder. */

0 commit comments

Comments
 (0)