[Lldb-commits] [lldb] [LLDB] Add type casting to DIL, part 3 of 3 (PR #175061)

via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 9 15:47:19 PST 2026


================
@@ -233,3 +259,17 @@ def test_type_cast(self):
         self.expect_var_path("((int*)arr_2d)[1]", type="int", value="2")
         self.expect_var_path("((int*)arr_2d)[2]", type="int", value="3")
         self.expect_var_path("((int*)arr_2d[1])[1]", type="int", value="5")
+
+        # Test casting to user-defined type with same name as variable.
+
+        self.expect_var_path("myStruct", type="myName")
+        self.expect_var_path("myName", type="int", value="37")
+
+        # Here 'myName' is treated as a variable, not a type, so '(myName)'
+        # is parsed as a variable expression and 'InnerFoo' is unexpected,
+        # and a type cast is not attempted.
+        self.expect(
+            "frame variable '(myName)InnerFoo'",
+            error=True,
+            substrs=["expected 'eof', got: <'InnerFoo' (identifier)>"],
----------------
cmtice wrote:

The basic error message that we're "matching" here in the test case is "expected 'particular-type-of-token', got <'text' (token-type)>". I'm not sure how what a better error message would look like, but I'm open to suggestions.

https://github.com/llvm/llvm-project/pull/175061


More information about the lldb-commits mailing list