mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 03:16:37 +00:00
[globals] Emit globals.set value lambda with declared global type
Pass the global's declared C++ type as the lambda return type so TemplatableFn stores a direct function pointer instead of hitting the deprecated converting trampoline when the value expression deduces to a different type (e.g. an int literal or int-returning lambda assigned to a float global).
This commit is contained in:
@@ -4,6 +4,14 @@ esphome:
|
||||
- globals.set:
|
||||
id: glob_int
|
||||
value: "10"
|
||||
# Set a float global with an integer literal - must emit the correct
|
||||
# return type so TemplatableFn stores a direct function pointer.
|
||||
- globals.set:
|
||||
id: glob_float
|
||||
value: "102"
|
||||
- globals.set:
|
||||
id: glob_float
|
||||
value: !lambda "return 42;"
|
||||
|
||||
globals:
|
||||
- id: glob_int
|
||||
|
||||
Reference in New Issue
Block a user