Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow different types for the second and third operands of conditional operator #1

Open
athos opened this issue Jun 26, 2019 · 0 comments

Comments

@athos
Copy link
Owner

athos commented Jun 26, 2019

According to JLS 15.25, typing the conditional operator never fails unless it includes an invocation of a void method. However, the current implementation throws VerifyError when the second and third operands differs in type:

user=> (defclass C ^String (defm m [^int x] (str (if (== x 0) "foo" 1))))
Syntax error (VerifyError) compiling at (REPL:1:1).
Bad type on operand stack
Exception Details:
  Location:
    user/C.m(I)Ljava/lang/String; @17: invokevirtual
  Reason:
    Type top (current frame, stack[1]) is not assignable to 'java/lang/String'
  Current Frame:
    bci: @17
    flags: { }
    locals: { 'user/C', integer }
    stack: { 'java/lang/StringBuilder', top }
  Bytecode:
    0000000: bb00 0e59 b700 0f1b 9a00 0812 11a7 0004
    0000010: 04b6 0015 b600 19b0                    
  Stackmap Table:
    same_locals_1_stack_item_frame(@16,Object[#14])
    full_frame(@17,{Object[#2],Integer},{Object[#14],Top})

user=> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant