• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

polserver / polserver / 17504812320

05 Sep 2025 09:23PM UTC coverage: 59.904% (+0.08%) from 59.826%
17504812320

push

github

web-flow
Add Escript support for uninitialized class functions (#808)

* update grammar

* AST nodes and test

* Address self-review comments
- Replace `super` comment with something more explanatory
- Rename `make_user_function`

* add class analysis for uninit functions

* fix ast test after disallowing static uninit funcs

* use std::ranges::find_if

* add tests

* use SUPER constant; add test

* Remove unreachable code leftover from #809

Since #809, the super function is only generated for a class when
registering a parent class, and therefore it will always have a body. A
"No base class defines a constructor" will only occur if super was never
generated, and is handled in the "No function linked through
FunctionResolver" section of semantic analyzer.

* Address review comments
- use std::ranges::move instead of move iterators
- use std::is_same_v<> vs std::is_same<>::value
- use switch vs chained ternary conditionals

* update escript guide, create tests that are in escript guide

* add core-changes

* Error on uninit and defined constructor

* Move methods' FunctionLink construction to builder

This allows the error message for the uninit function to have a "See
Also" that point to the defined function.

* Move error checks for uninit and defined functions

These semantic checks should be in the ... SemanticAnalyzer.

* fix typo in core-changes

154 of 168 new or added lines in 7 files covered. (91.67%)

1 existing line in 1 file now uncovered.

43860 of 73217 relevant lines covered (59.9%)

427918.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.25
/pol-core/bscript/compiler/model/UserFunctionType.h
1
#pragma once
2

3
#include <fmt/format.h>
4

5
namespace Pol::Bscript::Compiler
6
{
7
/*
8

9
Describes the type of a user function. In the following snippet:
10

11
    class Dog
12
      function Dog( this ) endfunction
13
      function eat ( this ) endfunction
14
      function StaticFunction() endfunction
15
    endclass
16

17
    function AnotherStaticFunction() endfunction
18

19
`Dog` is a Constructor function, `eat` is a Method user function, and
20
`StaticFunction` and `AnotherStaticFunction` are Static functions.
21

22
`Super` is a compiler-generated function, created when encountering a `super()`
23
call inside a constructor. A Super function call Constructor functionss
24
explicitly passing a `this`, whereas regularly a Constructor function call will
25
_generate_ a `this` argument.
26
 */
27
enum class UserFunctionType
28
{
29

30
  Static,
31
  Constructor,
32
  Method,
33
  Super,
34
};
35

36
}  // namespace Pol::Bscript::Compiler
37

38
template <>
39
struct fmt::formatter<Pol::Bscript::Compiler::UserFunctionType> : fmt::formatter<std::string>
40
{
41
  fmt::format_context::iterator format( const Pol::Bscript::Compiler::UserFunctionType& type,
32✔
42
                                        fmt::format_context& ctx ) const
43
  {
44
    using namespace Pol::Bscript::Compiler;
45
    std::string_view name;
32✔
46
    switch ( type )
32✔
47
    {
48
      using enum UserFunctionType;
49

50
    case Static:
2✔
51
      name = "static function";
2✔
52
      break;
2✔
53
    case Constructor:
12✔
54
      name = "class constructor";
12✔
55
      break;
12✔
56
    case Method:
18✔
57
      name = "class method";
18✔
58
      break;
18✔
NEW
59
    case Super:
×
NEW
60
      name = "super function";
×
NEW
61
      break;
×
62
    }
63
    return fmt::formatter<std::string>::format( name, ctx );
32✔
64
  }
65
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc