[
https://issues.apache.org/jira/browse/GROOVY-10359?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17862586#comment-17862586
]
Eric Milles edited comment on GROOVY-10359 at 7/2/24 8:35 PM:
--------------------------------------------------------------
Groovy supports numeric conversion to and from {{char}}. Here is an example:
https://github.com/apache/groovy/blob/08e1e8d5903db572283abd0f514f05ec60757f58/src/main/groovy/org/codehaus/groovy/util/StringUtil.groovy#L65
As a consequence, {{null}} may be encountered. Maybe a type-checking
extension could be more stringent.
Direct assignment of {{null}} produces a type-checking error: {{char c = null}}
Array assignment also produces a type-checking error: {{char[] c = new
Character[0]}} (see GROOVY-11371)
was (Author: emilles):
Groovy supports numeric conversion to and from {{char}}. As a consequence,
{{null}} may be encountered. Maybe a type-checking extension could be more
stringent.
Direct assignment of {{null}} produces a type-checking error: {{char c = null}}
Array assignment also produces a type-checking error: {{char[] c = new
Character[0]}} (see GROOVY-11371)
> STC misses type error when involving a variable with a char a declared type
> ---------------------------------------------------------------------------
>
> Key: GROOVY-10359
> URL: https://issues.apache.org/jira/browse/GROOVY-10359
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Thodoris Sotiropoulos
> Priority: Minor
>
> I have the following program
> {code:java}
> class Test {
> public static void main(String[] args) {
> char f = (Integer) null;
> }
> }
> {code}
> h3. Actual behaviour
> groovyc compiles this program
> h3. Expected behaviour.
> groovyc should have rejected this program with an error of the form:
> {code}
> error: incompatible types: Integer cannot be converted to char
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)