Skip to content

GATE v1.3.0 - the silent ones, and a comparison that chains

Latest

Choose a tag to compare

@Blade67 Blade67 released this 29 Nov 06:45

This one is almost entirely fixes. If you're using 1.2.0, upgrade: a lot of the bugs below
produced output that compiled, loaded, ran, and gave a different answer than your source
code asks for. The rest of this note is AI generated.

What was silently wrong

These are the ones worth reading, because nothing told you about them. Each compiled
without an error and produced an answer.

  • Two different generic instantiations could share one generated class. Four separate
    name collisions did this, and the second body silently replaced the first, so calls
    meant for one type ran the other type's code.
  • A trait's fields shifted a struct's positional constructor. Thing(1, 2) filled the
    wrong fields, and a struct packed into a Vector got its components in the wrong order.
  • The same declaration could be emitted two different ways in one build. GATE's
    project index read your files raw while the compile read them preprocessed, so in a
    project using @if one Pair(7, 8) came out as Vector2i and another as Vector3i.
  • An interface was satisfied by a member that did not match it. Conformance checked
    the name and the number of parameters and nothing else, so a wrong parameter type, a
    wrong return type, a static, a var or even a signal passed - and x is I then
    answered true for a class that could not do the job.
  • == over an array of structs compared by identity, while x[0] == needle on the
    same values compared by field, so the two disagreed.
  • A struct packed into a Vector answered is I with false for an interface it
    implements.

And these compiled with no error but produced a .gd Godot then refused to load, which
at least tells you something is wrong, only not what:

  • A generic named only in a declaration - a field, a parameter, a return type, an
    extends clause - was never recorded as used, so across files its instantiation was
    never emitted at all. Inside one file it always worked, which is what made it confusing.
  • namespace or trait used as an ordinary name. Godot reserves exactly those two of
    the words GATE adds, and they now get a proper error. struct, interface, requires
    and implements are not reserved by Godot and keep working as names, which was
    measured rather than assumed.
  • A cross-file @soa array reached through an instance slipped past its own
    documented compile error.
  • A hundred or more nested arrow lambdas reported success with zero diagnostics while
    writing out source truncated at the point the parser ran out of stack.

It no longer crashes Godot, and a command-line build is quiet

  • A segfault is fixed. Godot could die with no error and nothing in the log, taking the
    editor with it. GATE was handing it a script to reload that preloaded a path Godot still
    held in memory but which was already gone from disk, and 4.7.2 faults inside that call.
    GATE no longer asks.
  • Every command-line build printed an engine error, Can't retrieve singleton 'EditorInterface' outside of editor., followed by a second error from using what that
    call returns. Two separate places did it. Your CI log is clean now.
  • Breakpoints were refused on 17% of mapped lines. They work on those lines now.
  • A generic that instantiated itself hung the compiler instead of reporting the cycle.

Your comments stay put in more places

A comment on its own line immediately above an elif whose condition is wrapped in
parentheses across several lines was dropped. In 1.2.0 the same thing happened above a
plain elif and a plain else too. All of those are kept now.

Two places still lose one, unchanged from 1.2.0 and listed in the README: a comment inside
a lambda body passed as an argument, and one inside grouping parentheses, which has nothing
to attach to because GATE drops the parentheses and writes the expression out again.

Chained comparison

0 < hp < 100 means 0 < hp and hp < 100, and the shared operand is read once, so
0 < roll() < 10 rolls the dice once rather than twice.

It is only taken where GDScript could not have meant anything else. (0 < hp) < 100
compares a bool with an int, which Godot refuses outright, so there is nothing to lose.
Where GDScript's own reading is legal it is left alone: a < b < c on three bools stays as
written, and == and != never chain, because (a == b) == c is legal whatever the types.

A type that overloads < is left alone too, since a chain is built from the operator and
would never reach your overload. Where the reading that remains cannot work - an
operator < returning bool, so the chain would compare a bool with your type - you get
an error naming the chain instead of a .gd Godot rejects. An operator < that returns
the type itself still chains and calls your overload twice, because there the second
comparison means something.

The generated output changes shape

A class implementing an interface used to carry const __gate_impl := [...]; it now
carries one empty __gate_impl_<Iface> method per interface, so is I is a method lookup.
Nothing in a .gate changes.

Upgrading rebuilds your whole project once, by itself - the build cache is keyed partly on
the compiler's own files, so a new version invalidates it without your having to delete
anything. Expect every generated .gd to show a diff.

From the issue tracker

  • Generics in a class's members, #14, @toannth. This is the cross-file case above. The
    original answer to that issue was wrong: the syntax reported was correct and GATE was
    dropping the instantiation.

How this was found, since the test suite did not

Four bugs came from reading what people had reported. The rest came from going looking:
first through the compiler's core, then through the parts no one had audited - the editor
layer, the build cache, the sourcemap, the diagnostics, the preprocessor - and finally
through the test suite itself.

That last one mattered most. The suite was green before and after every round, and the
audit found why it could be: two stages were reporting OK having run zero test cases,
because a filter variable was being inherited by the processes they started. Every oracle
that compared values compared them as text, so an Array and an Array[int] looked
identical to it. And the fixed-point check was asymmetric about comments - duplicating one
broke it, while deleting one counted as a fixed point.

So the suite grew three stages and a floor under every existing one: a stage now has to
prove it actually executed its cases before it is allowed to report success. The last two
bugs in this release were found by sweeping 3,291 real .gd files from public projects,
compiling each one and recompiling its own output, which is the check that keeps finding
what the suite cannot.

Thanks to NekkoKan on the Discord, and to everyone who reported something.

Requires Godot 4.7+.