Skip to content
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
6 changes: 6 additions & 0 deletions tslang/lib/TypeScript/MLIRGenAccessCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,14 @@ namespace mlirgen
// whole discovery run over that; let the caller treat this as "unknown for
// now" (same idiom as mlirGenCallExpression's `!result.value &&
// genContext.allowPartialResolve` case above).
//
// It still says why: a message is shown only if the module then fails to compile,
// and one that does may fail in this very run, before any other run reaches the
// access - a function's return type is inferred this way. Without it the only error
// was what the caller made of no value, "the condition has no value" in an `if` (#442).
if (genContext.dummyRun || genContext.allowPartialResolve)
{
emitError(location, "Can't resolve property '") << name << "' of type " << to_print(objectValue.getType());
return mlir::success();
}

Expand Down
13 changes: 13 additions & 0 deletions tslang/test/tester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3207,6 +3207,19 @@ foreach(builtin_cast_case ${builtin_cast_cases})
FAIL_REGULAR_EXPRESSION "Stack dump|Assertion failed")
endforeach()

# A property that does not resolve is named in the error, in a condition too: the run inferring the
# function's return type gave no value and no message, and an `if` reported only "the condition has
# no value" (#442).
foreach(property_error_name if const while conditional)
add_test(NAME test-compile-property-error-${property_error_name}
COMMAND $<TARGET_FILE:tslang> --emit=obj --no-default-lib -mm=none
"${PROJECT_SOURCE_DIR}/test/tester/property-error/${property_error_name}.ts"
-o "${CMAKE_CURRENT_BINARY_DIR}/property-error-${property_error_name}.obj")
set_tests_properties(test-compile-property-error-${property_error_name}
PROPERTIES PASS_REGULAR_EXPRESSION "Can't resolve property 'foo' of type [{]x:s32[}]"
FAIL_REGULAR_EXPRESSION "Stack dump|Assertion failed")
endforeach()

# The shared-component tier under the other two models. A shared library records the model
# it was built under, so both halves of a pair are built with the same flag - which is what
# these run. The file pairs are the default model's, verbatim.
Expand Down
7 changes: 7 additions & 0 deletions tslang/test/tester/property-error/conditional.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// A property that does not resolve is named in the error, wherever it is read (#442): during the
// run that infers main's return type the access gave no value and said nothing, so an `if` said
// only "the condition has no value".
function main() {
const o = { x: 1 };
print(o.foo ? 1 : 2);
}
8 changes: 8 additions & 0 deletions tslang/test/tester/property-error/const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// A property that does not resolve is named in the error, wherever it is read (#442): during the
// run that infers main's return type the access gave no value and said nothing, so an `if` said
// only "the condition has no value".
function main() {
const o = { x: 1 };
const v = o.foo;
print(v);
}
7 changes: 7 additions & 0 deletions tslang/test/tester/property-error/if.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// A property that does not resolve is named in the error, wherever it is read (#442): during the
// run that infers main's return type the access gave no value and said nothing, so an `if` said
// only "the condition has no value".
function main() {
const o = { x: 1 };
if (o.foo) print(1);
}
7 changes: 7 additions & 0 deletions tslang/test/tester/property-error/while.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// A property that does not resolve is named in the error, wherever it is read (#442): during the
// run that infers main's return type the access gave no value and said nothing, so an `if` said
// only "the condition has no value".
function main() {
const o = { x: 1 };
while (o.foo) print(1);
}
Loading