fix: correctly initialize FunInfo<> object when calling a model field

This commit is contained in:
Tomasz Sowa 2023-02-22 00:38:36 +01:00
parent 369cefacdf
commit 5814bfca0d
Signed by: tomasz.sowa
GPG Key ID: 662CC1438638588B
2 changed files with 5 additions and 3 deletions

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2007-2016, Tomasz Sowa * Copyright (c) 2007-2023, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -201,7 +201,7 @@ struct FunInfo
// for other statements than [for] this is always zero // for other statements than [for] this is always zero
size_t iter; size_t iter;
// // an item from the tree
const Item & item; const Item & item;

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2007-2021, Tomasz Sowa * Copyright (c) 2007-2023, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -1652,12 +1652,14 @@ bool Generator<StreamType, is_pikotools_stream, is_autoescape_stream>::CallModel
if( parameters.empty() ) if( parameters.empty() )
{ {
FunInfo<StreamType> info(out_stream, parameters, empty, in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item); FunInfo<StreamType> info(out_stream, parameters, empty, in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item);
PrepareEnvStruct(info);
found = model.get_raw_value(nullptr, field.c_str(), nullptr, info, str, false); found = model.get_raw_value(nullptr, field.c_str(), nullptr, info, str, false);
last_res = info.res; last_res = info.res;
} }
else else
{ {
FunInfo<StreamType> info(out_stream, parameters, parameters[0].str, in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item); FunInfo<StreamType> info(out_stream, parameters, parameters[0].str, in_stream, stack_tab[stack_index-1], *stack_tab[stack_index-1].item);
PrepareEnvStruct(info);
found = model.get_raw_value(nullptr, field.c_str(), nullptr, info, str, false); found = model.get_raw_value(nullptr, field.c_str(), nullptr, info, str, false);
last_res = info.res; last_res = info.res;
} }