quick-lint-js icon indicating copy to clipboard operation
quick-lint-js copied to clipboard

Warn on unused arrow expression

Open singalhimanshu opened this issue 2 years ago • 3 comments

The following code:

async () => {}

Should report error_unused_arrow_expression Fix: #659

singalhimanshu avatar Mar 05 '22 05:03 singalhimanshu

(The CI self-check failure is my fault, not yours.)

strager avatar Mar 05 '22 09:03 strager

@strager I'm getting this error, don't know where it is coming from:

[9/114] Building CXX object src/CMakeFiles/quick-lint-js-lib.dir/diagnostic.cpp.o
FAILED: src/CMakeFiles/quick-lint-js-lib.dir/diagnostic.cpp.o 
/usr/bin/clang++ -DBOOST_ALL_NO_LIB -DBOOST_CONTAINER_NO_LIB -DBOOST_EXCEPTION_MINI_BOOST -DBOOST_NO_EXCEPTIONS -DQLJS_FEATURE_VECTOR_PROFILING=0 -DQUICK_LINT_JS_VERSION=2.4.1 -DSIMDJSON_EXCEPTIONS=0 -DSIMDJSON_THREADS_ENABLED=1 -DWIN32_LEAN_AND_MEAN -I../src/. -isystem ../vendor/boost -isystem ../vendor/simdjson/include -g -fchar8_t -fno-exceptions -fno-rtti -fdata-sections -ffunction-sections -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/himanshu/repos/quick-lint-js/build/src/CMakeFiles/quick-lint-js-lib.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/himanshu/repos/quick-lint-js/build/src/CMakeFiles/quick-lint-js-lib.dir/cmake_pch.hxx -MD -MT src/CMakeFiles/quick-lint-js-lib.dir/diagnostic.cpp.o -MF src/CMakeFiles/quick-lint-js-lib.dir/diagnostic.cpp.o.d -o src/CMakeFiles/quick-lint-js-lib.dir/diagnostic.cpp.o -c ../src/diagnostic.cpp
../src/diagnostic.cpp:161:5: error: constexpr variable 'all_diagnostic_infos' must be initialized by a constant expression
    all_diagnostic_infos[] = {
    ^                        ~
../src/./quick-lint-js/translation-table-generated.h:436:3: note: subexpression not valid in a constant expression
  QLJS_CONSTEXPR_ASSERT(false);
  ^
../src/./quick-lint-js/assert.h:88:7: note: expanded from macro 'QLJS_CONSTEXPR_ASSERT'
      asm("");                     \
      ^
../src/./quick-lint-js/translation-table.h:28:12: note: in call to 'translation_table_const_hash_table_look_up({21, &"unused arrow function"[0]})'
    return translation_table_const_hash_table_look_up(s);
           ^
../src/./quick-lint-js/translation.h:55:13: note: in call to 'mapping_index_for_untranslated_string({21, &"unused arrow function"[0]})'
            translation_table::mapping_index_for_untranslated_string(
            ^
../src/./quick-lint-js/translation.h:74:10: note: in call to 'translatable_message(&"unused arrow function"[0], 21)'
  return translatable_message(raw_message, static_cast<int>(length));
         ^
../src/diagnostic.cpp:156:1: note: in call to 'operator""_translatable(&"unused arrow function"[0], 21)'
QLJS_X_DIAG_TYPES
^
../src/./quick-lint-js/diagnostic-types.h:1494:15: note: expanded from macro 'QLJS_X_DIAG_TYPES'
      MESSAGE(QLJS_TRANSLATABLE("unused arrow function"), where))              \
              ^
../src/./quick-lint-js/translation.h:23:33: note: expanded from macro 'QLJS_TRANSLATABLE'
#define QLJS_TRANSLATABLE(...) (__VA_ARGS__##_translatable)
                                ^
<scratch space>:130:1: note: expanded from here
"unused arrow function"_translatable
^
../src/diagnostic.cpp:164:9: note: in call to 'get()'
        QLJS_X_DIAG_TYPES
        ^
../src/./quick-lint-js/diagnostic-types.h:1491:3: note: expanded from macro 'QLJS_X_DIAG_TYPES'
  QLJS_DIAG_TYPE(                                                              \
  ^
../src/diagnostic.cpp:163:3: note: expanded from macro 'QLJS_DIAG_TYPE'
  info_for_diagnostic<name>::get(),
  ^
1 error generated.

singalhimanshu avatar Apr 22 '22 07:04 singalhimanshu

@strager I'm getting this error, don't know where it is coming from:

Read the comment above the code for the second diagnostic from your compiler:

../src/./quick-lint-js/translation-table-generated.h:436:3: note: subexpression not valid in a constant expression https://github.com/quick-lint/quick-lint-js/blob/536043c105df9d176cd3693496817576aa7d4a29/src/quick-lint-js/translation-table-generated.h#L434-L436

strager avatar Apr 22 '22 07:04 strager