1.1 --- a/templates/ops.c Thu Jul 12 15:25:53 2018 +0200
1.2 +++ b/templates/ops.c Thu Jul 12 16:46:25 2018 +0200
1.3 @@ -1,6 +1,6 @@
1.4 /* Common operations.
1.5
1.6 -Copyright (C) 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk>
1.7 +Copyright (C) 2015, 2016, 2017, 2018 Paul Boddie <paul@boddie.org.uk>
1.8
1.9 This program is free software; you can redistribute it and/or modify it under
1.10 the terms of the GNU General Public License as published by the Free Software
1.11 @@ -231,7 +231,7 @@
1.12
1.13 /* Context-related operations. */
1.14
1.15 -int __test_context_update(__attr context, __attr attr)
1.16 +int __test_context_update(__attr context, __attr attr, int invoke)
1.17 {
1.18 /* Return whether the context should be updated for the attribute. */
1.19
1.20 @@ -258,6 +258,11 @@
1.21 __raise_type_error();
1.22 }
1.23
1.24 + /* Without a null or instance context, an invocation cannot be performed. */
1.25 +
1.26 + if (invoke)
1.27 + __raise_unbound_method_error();
1.28 +
1.29 /* Test for access to a type class attribute using a type instance. */
1.30
1.31 if (__test_specific_type(attrcontextvalue, &__TYPE_CLASS_TYPE) && __is_type_instance(__VALUE(context)))
1.32 @@ -272,7 +277,7 @@
1.33 {
1.34 /* Update the context or return the unchanged attribute. */
1.35
1.36 - if (__test_context_update(context, attr))
1.37 + if (__test_context_update(context, attr, 0))
1.38 return __update_context(context, attr);
1.39 else
1.40 return attr;
1.41 @@ -288,7 +293,7 @@
1.42 /* Revert the local context to that employed by the attribute if the
1.43 supplied context is not appropriate. */
1.44
1.45 - if (!__test_context_update(context, attr))
1.46 + if (!__test_context_update(context, attr, 1))
1.47 contexts[target] = __CONTEXT_AS_VALUE(attr);
1.48 return attr;
1.49 }
1.50 @@ -297,7 +302,7 @@
1.51 {
1.52 /* Set the local context to the specified context if appropriate. */
1.53
1.54 - if (__test_context_update(context, __ATTRVALUE(value)))
1.55 + if (__test_context_update(context, __ATTRVALUE(value), 1))
1.56 contexts[target] = context;
1.57 return __ATTRVALUE(value);
1.58 }