Skip to content

[SwiftExpressionParser] Suppress spurious variable lookup errors #8903

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1775,8 +1775,9 @@ SwiftExpressionParser::Parse(DiagnosticManager &diagnostic_manager,
"Missing type debug information for variable \"%s\": %s",
var.GetName().str().str().c_str(),
llvm::toString(std::move(error)).c_str());
return ParseResult::unrecoverable_error;
}

// Otherwise print the diagnostics from the Swift compiler.
DiagnoseSwiftASTContextError();
return ParseResult::unrecoverable_error;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TestSwiftExpressionErrorReportingy(TestBase):
NO_DEBUG_INFO_TESTCASE = True

@swiftTest
def test(self):
def test_missing_var(self):
"""Test error reporting in expressions reports
only diagnostics in user code"""
self.build()
Expand All @@ -31,3 +31,24 @@ def check(value):
value = self.frame().EvaluateExpression(
"ceciNestPasUnVar", options)
check(value)

@swiftTest
def test_missing_type(self):
"""Test error reporting in expressions reports
only diagnostics in user code"""
self.build(dictionary={'HIDE_SWIFTMODULE': 'YES'})
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
self, 'break here', lldb.SBFileSpec('main.swift'))

options = lldb.SBExpressionOptions()
value = self.frame().EvaluateExpression("strct", options)
def check(value):
lines = str(value.GetError()).split('\n')
self.assertTrue(lines[0].startswith('error:'))
self.assertIn('Missing type', lines[0])
self.assertIn('strct', lines[0])
for line in lines[1:]:
self.assertFalse(line.startswith('error:'))
self.assertFalse(line.startswith('warning:'))

check(value)
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ class State {
print("in class") // break here
}

var number:Int
var number : Int
}

func f() {
struct S {}

func f(_ strct : S) {
print("in function") // break here
}

f()
f(S())
State(x: 20)