Bug 205663

Summary: YCP (yast2-core) - Reference to Integer doesn't work
Product: [openSUSE] openSUSE 10.3 Reporter: Lukas Ocilka <locilka>
Component: YaST2Assignee: Martin Vidner <mvidner>
Status: RESOLVED WONTFIX QA Contact: Jiri Srain <jsrain>
Severity: Normal    
Priority: P3 - Medium CC: aschnell, kkaempf
Version: Alpha 1   
Target Milestone: unspecified   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Lukas Ocilka 2006-09-14 09:15:24 UTC
See this example:

{
    void ChangeInteger (integer & in) {
        y2milestone("Changing from %1", in);
        in = 2;
    }
    
    integer in1 = 1;
    
    y2milestone("Old Integer: %1", in1);
    ChangeInteger(in1);
    y2milestone("New Integer: %1", in1);
}

It should work but ycpc reports:
parsing 'ref_int.ycp'
ref_int.ycp:4  [Parser] type mismatch in assignment
ref_int.ycp:4  [Parser] Expected 'integer &', seen 'const integer'.
Error

This works for 'map' and 'string' (both tested), I hope it works for the other types as well.
Comment 1 Martin Vidner 2006-09-21 15:16:55 UTC
Apparently there is a bug in Type::basematch:
    if (expected->isReference()
	&& (!expected->isConst()
	    && isConst()))
    {
#if DO_DEBUG
	y2debug ("doesn't expect const");
#endif
	return -1;
    }
I don't know what this means, it may intend to prevent initializing a reference to a const to something that is not a const, but it swaps "this" and "expected".
It happens to work for strings, because string literals are of type string, not const string. Weird.
Comment 2 Martin Vidner 2006-11-14 11:29:03 UTC
I will not fix this bug for 10.2. Moving to 10.3
Comment 3 Martin Vidner 2008-07-14 13:55:33 UTC
*** Bug 408891 has been marked as a duplicate of this bug. ***
Comment 4 Stanislav Visnovsky 2008-09-25 12:37:14 UTC
float fails as well. The reason is that integer and float constants are 'const' while string, map and list are not.
Comment 5 Klaus Kämpf 2010-04-12 14:08:46 UTC
wontfix