wurstscript / WurstScript

Programming language and toolkit to create Warcraft III Maps
https://wurstlang.org
Apache License 2.0
225 stars 30 forks source link

Extending closure interfaces results in pjass failure #781

Open theQuazz opened 5 years ago

theQuazz commented 5 years ago

The following code breaks when I run the map at the injecting mapscript phase

package Tmp
import LinkedList

public interface Function<S, R>
    function call(S s) returns R

public interface Predicate<S> extends Function<S, bool>

public function every<T>(Predicate<T> predicate, LinkedList<T> list) returns bool
    let iter = list.iterator()
    for elem from iter
        if not predicate.call(elem)
            return false
    iter.close()
    return true

public function every<T>(Predicate<T> predicate) returns Predicate<LinkedList<T>>
    return list -> every(predicate, list)

public function LinkedList<T>.every<T>(Predicate<T> predicate) returns bool
    return every(predicate, this)

init
    asList(1, 2, 3).every(x -> x >= 1)

I can fix it by not extending Function<S, bool> from Predicate<S>

package Tmp

import LinkedList

public interface Function<S, R>
    function call(S s) returns R

public interface Predicate<S>
    function call(S s) returns bool

public function every<T>(Predicate<T> predicate, LinkedList<T> list) returns bool
    let iter = list.iterator()
    for elem from iter
        if not predicate.call(elem)
            return false
    iter.close()
    return true

public function every<T>(Predicate<T> predicate) returns Predicate<LinkedList<T>>
    return list -> every(predicate, list)

public function LinkedList<T>.every<T>(Predicate<T> predicate) returns bool
    return every(predicate, this)

init
    asList(1, 2, 3).every(x -> x >= 1)

image

2018-12-19 23:54:32 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - C:\Users\Jesse\island-troll-tribes\_build\WurstRunMap.w3x 
2018-12-19 23:54:32 [Wurst LanguageWorker] WARN  systems.crigges.jmpq3.JMpqEditor - mpq's listfile is incomplete. Blocks without listfile entry will be discarded 
2018-12-19 23:54:32 [Wurst LanguageWorker] DEBUG s.crigges.jmpq3.AttributesFile - parsed attributes 
2018-12-19 23:55:04 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Building mpq 
2018-12-19 23:55:04 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Sorted blocks 
2018-12-19 23:55:04 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added existing files 
2018-12-19 23:55:04 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file war3map.w3u 
2018-12-19 23:55:04 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file war3map.w3t 
2018-12-19 23:55:04 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file war3map.w3b 
2018-12-19 23:55:04 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file war3map.w3d 
2018-12-19 23:55:04 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file war3map.w3a 
2018-12-19 23:55:04 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file war3map.w3h 
2018-12-19 23:55:04 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file war3map.w3q 
2018-12-19 23:55:04 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file AxeTroll.mdx 
2018-12-19 23:55:04 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file AxeTroll_Portrait.mdx 
2018-12-19 23:55:04 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file Bandit.blp 
2018-12-19 23:55:04 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file ChaosTrollNecromancer.blp 
2018-12-19 23:55:04 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file ChaosTrollNecromancer.mdx 
2018-12-19 23:55:04 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file ChaosTrollNecromancer_Portrait.mdx 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file DrakkariHero.mdx 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file DrakkariHero_Portrait.mdx 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file dummy.mdx 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file ForestTrollCaster.mdx 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file ForestTrollCaster_Portrait.mdx 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file HeroShadowHunter.blp 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file Noktal the Savage.mdx 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file Noktal the Savage_Portrait.mdx 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file Shama1.mdx 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file Textures\Shama1.blp 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file Textures\TrollShaman.blp 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file TrollShaman.mdx 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file TrollShaman_Portrait.mdx 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added file war3map.imp 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added new files 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added listfile 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Rebuild complete. Took: 602ms 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - C:\Users\Jesse\island-troll-tribes\_build\WurstRunMap.w3x 
2018-12-19 23:55:05 [Wurst LanguageWorker] WARN  systems.crigges.jmpq3.JMpqEditor - mpq's listfile is incomplete. Blocks without listfile entry will be discarded 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Building mpq 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Sorted blocks 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added existing files 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added new files 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Added listfile 
2018-12-19 23:55:05 [Wurst LanguageWorker] DEBUG systems.crigges.jmpq3.JMpqEditor - Rebuild complete. Took: 124ms
peq commented 5 years ago

Primitive types are not handled very well by the current generics design. I think you have to wait for #679 for this to get fixed.