OpenTTD / OpenTTD/nml

Unexpected internal error has occurred.

Open
#394 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
59
Forks
46
Avg merge
11d 15h
Merged PRs (30d)
3

Description

NML version

https://github.com/PeterN/nml/tree/station-bridges#

Error message

 nmlc ERROR: nmlc: An internal error has occurred:
nmlc-version: 0.4.5.post20250901+station.bridges.gb0a3bee1
Error:    (NotImplementedError) "reduce must be implemented in expression-subclass <class 'nml.actions.action2layout.StationSpriteset'>".
Command:  ['/usr/local/bin/nmlc', '-c', '--verbosity=4', '--no-optimisation-warning', '--grf=generated/Polish_Stations.grf', 'generated/Polish_Stations.nml']
Location: File "/usr/local/lib/python3.11/dist-packages/nml-0.4.5.post20250901+station.bridges.gb0a3bee1-py3.11-linux-x86_64.egg/nml/expression/base_expression.py", line 70, in reduce

And with -s flag

  File "/usr/local/bin/nmlc", line 33, in <module>
    sys.exit(load_entry_point('nml==0.4.5.post20250901+station.bridges.gb0a3bee1', 'console_scripts', 'nmlc')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/nml-0.4.5.post20250901+station.bridges.gb0a3bee1-py3.11-linux-x86_64.egg/nml/main.py", line 637, in run
    main(sys.argv[1:])
  File "/usr/local/lib/python3.11/dist-packages/nml-0.4.5.post20250901+station.bridges.gb0a3bee1-py3.11-linux-x86_64.egg/nml/main.py", line 343, in main
    ret = nml(
          ^^^^
  File "/usr/local/lib/python3.11/dist-packages/nml-0.4.5.post20250901+station.bridges.gb0a3bee1-py3.11-linux-x86_64.egg/nml/main.py", line 447, in nml
    tmp_actions = result.get_action_list()
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/nml-0.4.5.post20250901+station.bridges.gb0a3bee1-py3.11-linux-x86_64.egg/nml/ast/base_statement.py", line 164, in get_action_list
    action_list.extend(stmt.get_action_list())
                       ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/nml-0.4.5.post20250901+station.bridges.gb0a3bee1-py3.11-linux-x86_64.egg/nml/ast/item.py", line 112, in get_action_list
    return base_statement.BaseStatementList.get_action_list(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/nml-0.4.5.post20250901+station.bridges.gb0a3bee1-py3.11-linux-x86_64.egg/nml/ast/base_statement.py", line 164, in get_action_list
    action_list.extend(stmt.get_action_list())
                       ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/nml-0.4.5.post20250901+station.bridges.gb0a3bee1-py3.11-linux-x86_64.egg/nml/ast/item.py", line 271, in get_action_list
    return action3.parse_graphics_block(self, item_feature, item_id, item_size)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/nml-0.4.5.post20250901+station.bridges.gb0a3bee1-py3.11-linux-x86_64.egg/nml/actions/action3.py", line 289, in parse_graphics_block
    action_list.extend(parse_graphics_block_single_id(graphics_block, feature, id, is_livery_override))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/nml-0.4.5.post20250901+station.bridges.gb0a3bee1-py3.11-linux-x86_64.egg/nml/actions/action3.py", line 355, in parse_graphics_block_single_id
    actions, var10map, registers_ref = action2layout.parse_station_layouts(
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/nml-0.4.5.post20250901+station.bridges.gb0a3bee1-py3.11-linux-x86_64.egg/nml/actions/action2layout.py", line 734, in parse_station_layouts
    layout_registers.parse(varact2parser)
  File "/usr/local/lib/python3.11/dist-packages/nml-0.4.5.post20250901+station.bridges.gb0a3bee1-py3.11-linux-x86_64.egg/nml/actions/action2layout.py", line 527, in parse
    varact2parser.parse_expr(expr)
  File "/usr/local/lib/python3.11/dist-packages/nml-0.4.5.post20250901+station.bridges.gb0a3bee1-py3.11-linux-x86_64.egg/nml/actions/action2var.py", line 692, in parse_expr
    self.parse(expr)
  File "/usr/local/lib/python3.11/dist-packages/nml-0.4.5.post20250901+station.bridges.gb0a3bee1-py3.11-linux-x86_64.egg/nml/actions/action2var.py", line 701, in parse
    expr = self.preprocess_binop(expr)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/nml-0.4.5.post20250901+station.bridges.gb0a3bee1-py3.11-linux-x86_64.egg/nml/actions/action2var.py", line 411, in preprocess_binop
    return expr.reduce()
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/nml-0.4.5.post20250901+station.bridges.gb0a3bee1-py3.11-linux-x86_64.egg/nml/expression/binop.py", line 80, in reduce
    expr1 = self.expr1.reduce(id_dicts)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/nml-0.4.5.post20250901+station.bridges.gb0a3bee1-py3.11-linux-x86_64.egg/nml/expression/base_expression.py", line 70, in reduce
    raise NotImplementedError("reduce must be implemented in expression-subclass {!r}".format(type(self)))
NotImplementedError: reduce must be implemented in expression-subclass <class 'nml.actions.action2layout.StationSpriteset'>

What caused it

spritelayout layout_FRONT_X {br}
	ground {br}
-		sprite: 1012;
+		sprite: CUSTOM(1) + 1;
	{_br}
	building {br}
		sprite: DEFAULT(1);
		zextent: {zextent};
		recolour_mode:	RECOLOUR_REMAP;
		palette:		CUSTOM(0);
	{_br}
{_br}

spritelayout layout_FRONT_Y {
	ground {
-		sprite: 1011;
+		sprite: CUSTOM(1);
	}
	building {
		sprite: DEFAULT(3);
		zextent: {zextent};
		recolour_mode:	RECOLOUR_REMAP;
		palette:		CUSTOM(0);
	}
}

+ switch (FEAT_STATIONS, SELF, GROUND_sprite_switch, terrain_type) {
+	TILETYPE_DESERT: 1037;
+	1011;
+ }

item (FEAT_STATIONS, tile_1_1) {
	graphics {
		sprite_layouts:	[layout_FRONT_X, layout_FRONT_Y];

// first spriteset always exist and has no cargo on it
		default:		spriteset_1_0;
-		custom_spritesets: [palette_switch];
+		custom_spritesets: [palette_switch, GROUND_sprite_switch];
		purchase:		spriteset_1_0;
		select_tile_type: 0; // can be 0 - 255 since nml 0.7.6
		PASS: random_1_PASS;
	}
}

NML file and files needed to compile

Polish_Stations.nml.zip
images.zip
lang.zip

Source code

https://codeberg.org/Rito12/OpenTTDPolishStations/src/branch/NML_internal_error_bug_report

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the shown nmlc command and the attached Polish_Stations.nml input. Start with nml/actions/action2layout.py, especially StationSpriteset, then inspect expression/base_expression.py and actions/action2var.py along the reported stack. Done means the supplied input compiles without the NotImplementedError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.