;; -*-theme-d-*-

;; Copyright (C) 2016 Tommi Höynälänmaa
;; Distributed under GNU General Public License version 3,
;; see file doc/GPL-3.

;; Expected results: translation error
;;   multiple primitive class definitions for the same predicate

(define-proper-program (tests test396)

  (import (standard-library core)
	  (standard-library console-io))

  (define-prim-class <bytevector>
    #f #f #f bytevector-zero
    bytevector? eq? eq? eq?)

  (define-prim-class <bytevector2>
    #f #f #f bytevector-zero2
    bytevector? eq? eq? eq?)

  (define bytevector-u8-ref
    (prim-proc bytevector-u8-ref (<bytevector> <integer>) <integer> (pure)))

  (define bytevector-length
    (prim-proc bytevector-length (<bytevector>) <integer> (pure)))

  (define make-bytevector2
    (prim-proc make-bytevector (<integer> <integer>) <bytevector2> (pure)))

  (define-simple-proc display-bytevector (((bv <bytevector>)) <none> (nonpure))
    (let ((len (bytevector-length bv)))
      (do ((i <integer> 0 (+ i 1))) ((>= i len))
	(console-display (bytevector-u8-ref bv i))
	(console-newline))))

  (define-simple-proc main (() <none> nonpure)
    (let ((bv (make-bytevector2 10 1)))
      (display-bytevector bv)
      (display-bytevector (zero <bytevector>))
      (display-bytevector (zero <bytevector2>)))))

