Skip to content

Commit 3f6a926

Browse files
authored
Improve type checking errors with structs (#761)
Change the implementation of TypeSpec::string(), which returns the text representation of a TypeSpec, so that it prints the name of the struct rather than just its numerical designation. An example of the old behavior, as applied to a type checking error message: test.osl:10: error: No matching function call to 'max (struct 1, struct 1)' Candidates are: int max (int, int) float max (float, float) ... And the new behavior: test.osl:10: error: No matching function call to 'max (struct vector4, struct vector4)'
1 parent b8f8b2b commit 3f6a926

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/liboslexec/typespec.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ TypeSpec::string () const
7676
str += Strutil::format ("[%d]", arraylength());
7777
}
7878
else if (structure() > 0) {
79-
str += Strutil::format ("struct %d", structure());
79+
StructSpec *ss = structspec();
80+
if (ss)
81+
str += Strutil::format ("struct %s", structspec()->name());
82+
else
83+
str += Strutil::format ("struct %d", structure());
8084
if (is_unsized_array())
8185
str += "[]";
8286
else if (arraylength() > 0)

0 commit comments

Comments
 (0)