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
7 changes: 7 additions & 0 deletions tslang/lib/TypeScript/MLIRGenClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,13 @@ namespace mlirgen
},
genContext);

// a failed initializer (e.g. `null` for a `Ref<string>`) leaves no type; going on with
// none dropped its diagnostic, since those are only shown when the module fails
if (!staticFieldType)
{
return mlir::failure();
}

auto &staticFieldInfos = newClassPtr->staticFields;
pushStaticField(staticFieldInfos, fieldId, staticFieldType, fullClassStaticFieldName, -1, accessLevel);

Expand Down
8 changes: 8 additions & 0 deletions tslang/test/tester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2939,6 +2939,14 @@ add_test(NAME test-compile-diagnostic-location-field-initializer
set_tests_properties(test-compile-diagnostic-location-field-initializer
PROPERTIES PASS_REGULAR_EXPRESSION "field_initializer\\.ts:6:5: error: can't cast from 'null' to 'Reference<string>'"
FAIL_REGULAR_EXPRESSION "Stack dump|Assertion failed|field_initializer\\.ts:1:")
# A static field's initializer is checked like an instance field's: it compiled with no error at all.
add_test(NAME test-compile-diagnostic-location-static-field-initializer
COMMAND $<TARGET_FILE:tslang> --emit=obj --no-default-lib -mm=none
"${PROJECT_SOURCE_DIR}/test/tester/diagnostic-location/static_field_initializer.ts"
-o "${CMAKE_CURRENT_BINARY_DIR}/diagnostic-location-static-field-initializer.obj")
set_tests_properties(test-compile-diagnostic-location-static-field-initializer
PROPERTIES PASS_REGULAR_EXPRESSION "static_field_initializer\\.ts:6:32: error: can't cast from 'null' to 'Reference<string>' in 'strict null mode'"
FAIL_REGULAR_EXPRESSION "Stack dump|Assertion failed|static_field_initializer\\.ts:1:")
add_test(NAME test-compile-diagnostic-location-implicit-constructor
COMMAND $<TARGET_FILE:tslang> --emit=obj --no-default-lib -mm=none
"${PROJECT_SOURCE_DIR}/test/tester/diagnostic-location/implicit_constructor.ts"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// A static field's failed initializer compiled with no diagnostic: the field was registered
// without a type, and the error, postponed like every message, was never shown.

class Args {
static count = 1;
static argv: Ref<string> = null;
}
Loading