rusty
rusty copied to clipboard
ANY_BIT generics resolve as BOOL when given a literal DINT
So the problem is that SHL is defined only for ANY_BIT types in the norm, and the numbers used here are treated as DINT
This is a bug, since we should be able to define numbers as have them treated as bit for bit only operations.
The fact that the generic resolver also reverted to BOOL is strange.
This code will work but it's oviously had to change a project to behave like this:
FUNCTION main : DINT
var
num1 : dint ;
end_var
num1 := SHL(WORD#16#2345, WORD#16);
num1 := SHL(WORD#4, WORD#16);
END_FUNCTION
Originally posted by @ghaith in https://github.com/PLC-lang/rusty/discussions/1030#discussioncomment-7700081