问题标签 [unreachable-statement]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
5566 浏览

php - PHP 中无法访问的语句

好的,我正在尝试使用 PHP 为我的网站的服务器端编写一个程序。使用 Netbeans 作为我选择的 IDE,我在尝试编写将单行存储在关联数组中的函数时遇到了错误。当我尝试返回变量 $SelectedRow 时出现问题。它会导致“无法访问状态”警告。这导致程序在其表面上一落千丈。我可以让这段代码在不包含在函数中的情况下工作。但是,我真的不觉得这是在我学习编写程序时解决问题的方法。

旁注:这是我在 SO 上发布的第一个问题,因此非常感谢建设性的批评和提示。我很高兴发布任何有助于答案或任何其他类型的规范。我不相信这是一个所谓的“副本”问题,因为到目前为止我还没有找到另一个解决 PHP 中相同问题的 SO 问题。如果有人对我的代码有任何建议,一般来说,我会很高兴听到,因为我才刚刚开始整个 CS 事情。

0 投票
5 回答
2165 浏览

java - 为什么 Java 编译器不会为无法访问的 then 语句生成无法访问的语句错误?

如果我尝试编译

Java 编译器产生一个错误,说Unreachable statement. 但是,如果我添加另一个“无法访问”(根据我)break声明并使它:

它编译。为什么它不会产生错误?

0 投票
4 回答
2452 浏览

java - if (boolean)unreachable statement in Java

this is for a intro programming class i am taking. I have created a Instance method to add a newValue to the totals. It has two parameters in the method: (a letter identifying the amount type, and amount) I was successful on the first parameter. the second is making me struggle. I am suppose to us an if statement. I made it so there is amount type, then i have three letters that are to be used that can be true. I set the if(amountType == false) and the compiler says its a "unreachable statement". The criteria for the if statement is "If the letter for the amount the is invalid (i.e. not T, D, or E), throw an IllegalArgumentException, and message back to user.

Any help would be appreciated.

0 投票
3 回答
182 浏览

java - 陷入错误循环:无法访问语句且未提供返回语句

这是我的代码片段:

所以错误表明缺少返回语句(不确定我错过了哪个场景)。但是当我在最后添加一个 return 语句时,它表明 return 语句无法访问。我在这里找到了一个有用的答案:Unreachable return statement still throws error,我尝试将它放在 try catch 块中,但它仍然要求返回语句。即使编译器知道我最后写的任何东西都是多余的,为什么它仍然显示错误?

0 投票
1 回答
69 浏览

java - 代码中显然有一个无法访问的语句,但可以编译 - 为什么?

第 2 行的语句永远不会执行,但编译器不会抱怨:

另一方面,取消注释第 1 行或第 3 行会导致“无法访问的语句”编译时错误。

我想知道为什么编译器如此不一致......

0 投票
0 回答
99 浏览

java - 当我尝试从 JSpinner 获取值时,为什么会出现这个无法访问的错误?

有人能帮我吗?我不断收到此错误,但不知道该怎么办。谢谢!!!

0 投票
1 回答
597 浏览

java - 在片段中使用 getActivity 返回后无法访问的语句

如果有人已经问过这个问题,我很抱歉,但我的应用程序不断出现错误。我什至无法运行,因为我收到“无法访问的声明”的错误消息。

这是我的片段上的代码

当我getActivity()在 my 上执行时ArrayAdapter,我List<Cours> listeCours;无法访问,我不知道为什么......

0 投票
1 回答
796 浏览

c++ - 由于编译时计算的值,如何避免“无法访问的语句”?

如果我编写以下 CUDA 代码:

我收到编译器警告:

我“感觉”我不应该收到此警告,因为无法访问的代码仅对于模板参数的某些值是无法访问的。如果我写“CPU等价物”,可以这么说:

并使用 gcc (5.4.0) 构建它 - 即使我使用-Wall.

现在,我可以通过写来规避这个

但我宁愿避免不得不颠倒我的逻辑来跳过nvcc的“箍”。我也可以写

但是 - 我不想缩进所有代码(同样的问题可能会再次发生,需要在 else 块内进行更多的缩进。

有什么我可以做的吗?另外,这不是一个“错误”,还是我应该将其报告为错误的错误功能?

0 投票
3 回答
608 浏览

android - url 中无法访问的语句

当我输入数据库 url 时,出现错误 Unreachable Statement

这是我的代码:

0 投票
1 回答
834 浏览

android - 它显示无法访问的语句错误

我正在尝试对选定的项目敬酒,但它显示无法访问的语句错误。

我的代码是: